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