]> git.proxmox.com Git - mirror_novnc.git/blame - karma.conf.js
Merge branch 'travis-lint' of https://github.com/CendioOssman/noVNC
[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++) {
cdb860ad
JD
23 for (let k = 0; k < versions.length; k++) {
24 let launcher_name = 'sl_' + platforms[j].replace(/[^a-zA-Z0-9]/g, '') + '_' + names[i];
e6af0f60
SR
25 if (versions[k]) {
26 launcher_name += '_' + versions[k];
27 }
28
29 customLaunchers[launcher_name] = {
30 base: 'SauceLabs',
31 browserName: names[i],
32 platform: platforms[j],
33 };
34
35 if (versions[i]) {
36 customLaunchers[launcher_name].version = versions[k];
37 }
38 }
39 }
40 }
41
42 browsers = Object.keys(customLaunchers);
43 } else {
44 useSauce = false;
dfae3209
SR
45 //browsers = ['PhantomJS'];
46 browsers = [];
e6af0f60
SR
47 }
48
cdb860ad 49 const my_conf = {
e6af0f60
SR
50
51 // base path that will be used to resolve all patterns (eg. files, exclude)
52 basePath: '',
53
54 // frameworks to use
55 // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
dfae3209 56 frameworks: ['requirejs', 'mocha', 'chai'],
e6af0f60
SR
57
58 // list of files / patterns to load in the browser (loaded in order)
59 files: [
dfae3209
SR
60 { pattern: 'vendor/sinon.js', included: false },
61 { pattern: 'node_modules/sinon-chai/lib/sinon-chai.js', included: false },
7279364c 62 { pattern: 'app/localization.js', included: false },
e0750f9b 63 { pattern: 'app/webutil.js', included: false },
dfae3209
SR
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: {
7279364c 93 'app/localization.js': ['babel'],
e0750f9b 94 'app/webutil.js': ['babel'],
dfae3209
SR
95 'core/**/*.js': ['babel'],
96 'tests/test.*.js': ['babel'],
97 'tests/fake.*.js': ['babel'],
98 'tests/assertions.js': ['babel'],
99 'vendor/pako/**/*.js': ['babel'],
e6af0f60
SR
100 },
101
dfae3209
SR
102 babelPreprocessor: {
103 options: {
cdb860ad 104 presets: transpileToES5 ? ['es2015'] : [],
dfae3209
SR
105 plugins: ['transform-es2015-modules-amd', 'syntax-dynamic-import'],
106 sourceMap: 'inline',
107 },
108 },
e6af0f60
SR
109
110 // test results reporter to use
111 // possible values: 'dots', 'progress'
112 // available reporters: https://npmjs.org/browse/keyword/karma-reporter
dfae3209 113 reporters: ['mocha'],
e6af0f60
SR
114
115
116 // web server port
117 port: 9876,
118
119
120 // enable / disable colors in the output (reporters and logs)
121 colors: true,
122
123
124 // level of logging
125 // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
126 logLevel: config.LOG_INFO,
127
128
129 // enable / disable watching file and executing tests whenever any file changes
130 autoWatch: false,
131
132 // Continuous Integration mode
133 // if true, Karma captures browsers, runs the tests and exits
134 singleRun: true,
135
136 // Increase timeout in case connection is slow/we run more browsers than possible
137 // (we currently get 3 for free, and we try to run 7, so it can take a while)
20d3fb66
SR
138 captureTimeout: 240000,
139
140 // similarly to above
141 browserNoActivityTimeout: 100000,
e6af0f60
SR
142 };
143
144 if (useSauce) {
dfae3209 145 my_conf.reporters.push('saucelabs');
f0e4548b 146 my_conf.captureTimeout = 0; // use SL timeout
e6af0f60
SR
147 my_conf.sauceLabs = {
148 testName: 'noVNC Tests (all)',
7e161007 149 startConnect: false,
f0e4548b 150 tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER
e6af0f60
SR
151 };
152 }
153
154 config.set(my_conf);
155};