]>
Commit | Line | Data |
---|---|---|
1 | // Karma configuration | |
2 | ||
3 | module.exports = function(config) { | |
4 | var customLaunchers = {}; | |
5 | var browsers = []; | |
6 | var useSauce = false; | |
7 | ||
8 | // use Sauce when running on Travis | |
9 | if (process.env.TRAVIS_JOB_NUMBER) { | |
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; | |
47 | //browsers = ['PhantomJS']; | |
48 | browsers = []; | |
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 | |
58 | frameworks: ['requirejs', 'mocha', 'chai'], | |
59 | ||
60 | // list of files / patterns to load in the browser (loaded in order) | |
61 | files: [ | |
62 | { pattern: 'vendor/sinon.js', included: false }, | |
63 | { pattern: 'node_modules/sinon-chai/lib/sinon-chai.js', included: false }, | |
64 | { pattern: 'app/localization.js', included: false }, | |
65 | { pattern: 'app/webutil.js', included: false }, | |
66 | { pattern: 'core/**/*.js', included: false }, | |
67 | { pattern: 'vendor/pako/**/*.js', included: false }, | |
68 | { pattern: 'tests/test.*.js', included: false }, | |
69 | { pattern: 'tests/fake.*.js', included: false }, | |
70 | { pattern: 'tests/assertions.js', included: false }, | |
71 | 'tests/karma-test-main.js', | |
72 | ], | |
73 | ||
74 | client: { | |
75 | mocha: { | |
76 | // replace Karma debug page with mocha display | |
77 | 'reporter': 'html', | |
78 | 'ui': 'bdd' | |
79 | } | |
80 | }, | |
81 | ||
82 | // list of files to exclude | |
83 | exclude: [ | |
84 | ], | |
85 | ||
86 | customLaunchers: customLaunchers, | |
87 | ||
88 | // start these browsers | |
89 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | |
90 | browsers: browsers, | |
91 | ||
92 | // preprocess matching files before serving them to the browser | |
93 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | |
94 | preprocessors: { | |
95 | 'app/localization.js': ['babel'], | |
96 | 'app/webutil.js': ['babel'], | |
97 | 'core/**/*.js': ['babel'], | |
98 | 'tests/test.*.js': ['babel'], | |
99 | 'tests/fake.*.js': ['babel'], | |
100 | 'tests/assertions.js': ['babel'], | |
101 | 'vendor/pako/**/*.js': ['babel'], | |
102 | }, | |
103 | ||
104 | babelPreprocessor: { | |
105 | options: { | |
106 | plugins: ['transform-es2015-modules-amd', 'syntax-dynamic-import'], | |
107 | sourceMap: 'inline', | |
108 | }, | |
109 | }, | |
110 | ||
111 | // test results reporter to use | |
112 | // possible values: 'dots', 'progress' | |
113 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter | |
114 | reporters: ['mocha'], | |
115 | ||
116 | ||
117 | // web server port | |
118 | port: 9876, | |
119 | ||
120 | ||
121 | // enable / disable colors in the output (reporters and logs) | |
122 | colors: true, | |
123 | ||
124 | ||
125 | // level of logging | |
126 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | |
127 | logLevel: config.LOG_INFO, | |
128 | ||
129 | ||
130 | // enable / disable watching file and executing tests whenever any file changes | |
131 | autoWatch: false, | |
132 | ||
133 | // Continuous Integration mode | |
134 | // if true, Karma captures browsers, runs the tests and exits | |
135 | singleRun: true, | |
136 | ||
137 | // Increase timeout in case connection is slow/we run more browsers than possible | |
138 | // (we currently get 3 for free, and we try to run 7, so it can take a while) | |
139 | captureTimeout: 240000, | |
140 | ||
141 | // similarly to above | |
142 | browserNoActivityTimeout: 100000, | |
143 | }; | |
144 | ||
145 | if (useSauce) { | |
146 | my_conf.reporters.push('saucelabs'); | |
147 | my_conf.captureTimeout = 0; // use SL timeout | |
148 | my_conf.sauceLabs = { | |
149 | testName: 'noVNC Tests (all)', | |
150 | startConnect: false, | |
151 | tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER | |
152 | }; | |
153 | } | |
154 | ||
155 | config.set(my_conf); | |
156 | }; |