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