]> git.proxmox.com Git - mirror_novnc.git/blob - karma.conf.js
Merge pull request #1013 from juanjoDiaz/es6_refactor_2
[mirror_novnc.git] / karma.conf.js
1 // Karma configuration
2
3 module.exports = function(config) {
4 const customLaunchers = {};
5 let browsers = [];
6 let useSauce = false;
7 let transpileToES5 = ['internet explorer'].includes(process.env.TEST_BROWSER_NAME);
8
9 // use Sauce when running on Travis
10 if (process.env.TRAVIS_JOB_NUMBER) {
11 useSauce = true;
12 }
13
14 if (useSauce && process.env.TEST_BROWSER_NAME && process.env.TEST_BROWSER_NAME != 'PhantomJS') {
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];
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;
48 //browsers = ['PhantomJS'];
49 browsers = [];
50 }
51
52 const my_conf = {
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
59 frameworks: ['requirejs', 'mocha', 'chai'],
60
61 // list of files / patterns to load in the browser (loaded in order)
62 files: [
63 { pattern: 'vendor/sinon.js', included: false },
64 { pattern: 'node_modules/sinon-chai/lib/sinon-chai.js', included: false },
65 { pattern: 'app/localization.js', included: false },
66 { pattern: 'app/webutil.js', included: false },
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',
73 ],
74
75 client: {
76 mocha: {
77 // replace Karma debug page with mocha display
78 'reporter': 'html',
79 'ui': 'bdd'
80 }
81 },
82
83 // list of files to exclude
84 exclude: [
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: {
96 'app/localization.js': ['babel'],
97 'app/webutil.js': ['babel'],
98 'core/**/*.js': ['babel'],
99 'tests/test.*.js': ['babel'],
100 'tests/fake.*.js': ['babel'],
101 'tests/assertions.js': ['babel'],
102 'vendor/pako/**/*.js': ['babel'],
103 },
104
105 babelPreprocessor: {
106 options: {
107 presets: transpileToES5 ? ['es2015'] : [],
108 plugins: ['transform-es2015-modules-amd', 'syntax-dynamic-import'],
109 sourceMap: 'inline',
110 },
111 },
112
113 // test results reporter to use
114 // possible values: 'dots', 'progress'
115 // available reporters: https://npmjs.org/browse/keyword/karma-reporter
116 reporters: ['mocha'],
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)
141 captureTimeout: 240000,
142
143 // similarly to above
144 browserNoActivityTimeout: 100000,
145 };
146
147 if (useSauce) {
148 my_conf.reporters.push('saucelabs');
149 my_conf.captureTimeout = 0; // use SL timeout
150 my_conf.sauceLabs = {
151 testName: 'noVNC Tests (all)',
152 startConnect: false,
153 tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER
154 };
155 }
156
157 config.set(my_conf);
158 };