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