]> git.proxmox.com Git - mirror_novnc.git/blob - karma.conf.js
Avoid big strings on the stack
[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 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', 'chai'],
57
58 // list of files / patterns to load in the browser (loaded in order)
59 files: [
60 { pattern: 'vendor/sinon.js', included: false },
61 { pattern: 'node_modules/sinon-chai/lib/sinon-chai.js', included: false },
62 { pattern: 'app/localization.js', included: false },
63 { pattern: 'app/webutil.js', included: false },
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',
70 ],
71
72 client: {
73 mocha: {
74 // replace Karma debug page with mocha display
75 'reporter': 'html',
76 'ui': 'bdd'
77 }
78 },
79
80 // list of files to exclude
81 exclude: [
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: {
93 'app/localization.js': ['babel'],
94 'app/webutil.js': ['babel'],
95 'core/**/*.js': ['babel'],
96 'tests/test.*.js': ['babel'],
97 'tests/fake.*.js': ['babel'],
98 'tests/assertions.js': ['babel'],
99 'vendor/pako/**/*.js': ['babel'],
100 },
101
102 babelPreprocessor: {
103 options: {
104 presets: transpileToES5 ? ['es2015'] : [],
105 plugins: ['transform-es2015-modules-amd', 'syntax-dynamic-import'],
106 sourceMap: 'inline',
107 },
108 },
109
110 // test results reporter to use
111 // possible values: 'dots', 'progress'
112 // available reporters: https://npmjs.org/browse/keyword/karma-reporter
113 reporters: ['mocha'],
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)
138 captureTimeout: 240000,
139
140 // similarly to above
141 browserNoActivityTimeout: 100000,
142 };
143
144 if (useSauce) {
145 my_conf.reporters.push('saucelabs');
146 my_conf.captureTimeout = 0; // use SL timeout
147 my_conf.sauceLabs = {
148 testName: 'noVNC Tests (all)',
149 startConnect: false,
150 tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER
151 };
152 }
153
154 config.set(my_conf);
155 };