]>
Commit | Line | Data |
---|---|---|
e6af0f60 SR |
1 | // Karma configuration |
2 | ||
651c23ec | 3 | module.exports = (config) => { |
cdb860ad JD |
4 | const customLaunchers = {}; |
5 | let browsers = []; | |
6 | let useSauce = false; | |
e6af0f60 | 7 | |
b081ea72 SR |
8 | // use Sauce when running on Travis |
9 | if (process.env.TRAVIS_JOB_NUMBER) { | |
e6af0f60 | 10 | useSauce = true; |
cdb860ad | 11 | } |
e6af0f60 SR |
12 | |
13 | if (useSauce && process.env.TEST_BROWSER_NAME && process.env.TEST_BROWSER_NAME != 'PhantomJS') { | |
cdb860ad JD |
14 | const names = process.env.TEST_BROWSER_NAME.split(','); |
15 | const platforms = process.env.TEST_BROWSER_OS.split(','); | |
16 | const versions = process.env.TEST_BROWSER_VERSION | |
17 | ? process.env.TEST_BROWSER_VERSION.split(',') | |
18 | : [null]; | |
19 | ||
20 | for (let i = 0; i < names.length; i++) { | |
21 | for (let j = 0; j < platforms.length; j++) { | |
cdb860ad JD |
22 | for (let k = 0; k < versions.length; k++) { |
23 | let launcher_name = 'sl_' + platforms[j].replace(/[^a-zA-Z0-9]/g, '') + '_' + names[i]; | |
e6af0f60 SR |
24 | if (versions[k]) { |
25 | launcher_name += '_' + versions[k]; | |
26 | } | |
27 | ||
28 | customLaunchers[launcher_name] = { | |
29 | base: 'SauceLabs', | |
30 | browserName: names[i], | |
31 | platform: platforms[j], | |
32 | }; | |
33 | ||
34 | if (versions[i]) { | |
35 | customLaunchers[launcher_name].version = versions[k]; | |
36 | } | |
37 | } | |
38 | } | |
39 | } | |
40 | ||
41 | browsers = Object.keys(customLaunchers); | |
42 | } else { | |
43 | useSauce = false; | |
dfae3209 SR |
44 | //browsers = ['PhantomJS']; |
45 | browsers = []; | |
e6af0f60 SR |
46 | } |
47 | ||
cdb860ad | 48 | const my_conf = { |
e6af0f60 SR |
49 | |
50 | // base path that will be used to resolve all patterns (eg. files, exclude) | |
51 | basePath: '', | |
52 | ||
53 | // frameworks to use | |
54 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter | |
7bcdbbc6 | 55 | frameworks: ['mocha', 'sinon-chai'], |
e6af0f60 SR |
56 | |
57 | // list of files / patterns to load in the browser (loaded in order) | |
58 | files: [ | |
7279364c | 59 | { pattern: 'app/localization.js', included: false }, |
e0750f9b | 60 | { pattern: 'app/webutil.js', included: false }, |
dfae3209 SR |
61 | { pattern: 'core/**/*.js', included: false }, |
62 | { pattern: 'vendor/pako/**/*.js', included: false }, | |
7bcdbbc6 | 63 | { pattern: 'vendor/browser-es-module-loader/dist/*.js*', included: false }, |
dfae3209 SR |
64 | { pattern: 'tests/test.*.js', included: false }, |
65 | { pattern: 'tests/fake.*.js', included: false }, | |
66 | { pattern: 'tests/assertions.js', included: false }, | |
7bcdbbc6 | 67 | 'vendor/promise.js', |
dfae3209 | 68 | 'tests/karma-test-main.js', |
e6af0f60 SR |
69 | ], |
70 | ||
71 | client: { | |
72 | mocha: { | |
dfae3209 SR |
73 | // replace Karma debug page with mocha display |
74 | 'reporter': 'html', | |
e6af0f60 SR |
75 | 'ui': 'bdd' |
76 | } | |
77 | }, | |
78 | ||
79 | // list of files to exclude | |
80 | exclude: [ | |
e6af0f60 SR |
81 | ], |
82 | ||
83 | customLaunchers: customLaunchers, | |
84 | ||
85 | // start these browsers | |
86 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | |
87 | browsers: browsers, | |
88 | ||
e6af0f60 SR |
89 | // test results reporter to use |
90 | // possible values: 'dots', 'progress' | |
91 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter | |
dfae3209 | 92 | reporters: ['mocha'], |
e6af0f60 SR |
93 | |
94 | ||
95 | // web server port | |
96 | port: 9876, | |
97 | ||
98 | ||
99 | // enable / disable colors in the output (reporters and logs) | |
100 | colors: true, | |
101 | ||
102 | ||
103 | // level of logging | |
104 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | |
105 | logLevel: config.LOG_INFO, | |
106 | ||
107 | ||
108 | // enable / disable watching file and executing tests whenever any file changes | |
109 | autoWatch: false, | |
110 | ||
111 | // Continuous Integration mode | |
112 | // if true, Karma captures browsers, runs the tests and exits | |
113 | singleRun: true, | |
114 | ||
115 | // Increase timeout in case connection is slow/we run more browsers than possible | |
116 | // (we currently get 3 for free, and we try to run 7, so it can take a while) | |
20d3fb66 SR |
117 | captureTimeout: 240000, |
118 | ||
119 | // similarly to above | |
120 | browserNoActivityTimeout: 100000, | |
e6af0f60 SR |
121 | }; |
122 | ||
123 | if (useSauce) { | |
dfae3209 | 124 | my_conf.reporters.push('saucelabs'); |
f0e4548b | 125 | my_conf.captureTimeout = 0; // use SL timeout |
e6af0f60 SR |
126 | my_conf.sauceLabs = { |
127 | testName: 'noVNC Tests (all)', | |
7e161007 | 128 | startConnect: false, |
f0e4548b | 129 | tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER |
e6af0f60 SR |
130 | }; |
131 | } | |
132 | ||
133 | config.set(my_conf); | |
134 | }; |