blob: 73650d30d1b896d6085f2afb6e242224ae8247b5 [file] [log] [blame]
Kevin Lubick556350d2018-10-12 15:21:17 -04001const isDocker = require('is-docker')();
2
3module.exports = function(config) {
4 // Set the default values to be what are needed when testing the
5 // WebAssembly build locally.
6 let cfg = {
7 // frameworks to use
8 // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
9 frameworks: ['jasmine'],
10
11 // list of files / patterns to load in the browser
12 files: [
13 { pattern: 'npm-wasm/bin/pathkit.wasm', included:false, served:true},
14 'perf/perfReporter.js',
15 'npm-wasm/bin/pathkit.js',
Kevin Lubickd2544352019-03-12 09:20:32 -040016 'tests/pathkitinit.js',
Kevin Lubick556350d2018-10-12 15:21:17 -040017 'perf/*.bench.js'
18 ],
19
20 proxies: {
21 '/pathkit/': '/base/npm-wasm/bin/'
22 },
23
24 // test results reporter to use
25 // possible values: 'dots', 'progress'
26 // available reporters: https://npmjs.org/browse/keyword/karma-reporter
27 reporters: ['dots'],
28
29 // web server port
30 port: 4444,
31
32 // enable / disable colors in the output (reporters and logs)
33 colors: true,
34
35 // level of logging
36 // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
37 logLevel: config.LOG_INFO,
38
39 // enable / disable watching file and executing tests whenever any file changes
40 autoWatch: true,
41
Kevin Lubickd2544352019-03-12 09:20:32 -040042 browserDisconnectTimeout: 20000,
43 browserNoActivityTimeout: 20000,
Kevin Lubick556350d2018-10-12 15:21:17 -040044
45 // start these browsers
46 browsers: ['Chrome'],
47
48 // Continuous Integration mode
49 // if true, Karma captures browsers, runs the tests and exits
50 singleRun: false,
51
52 // Concurrency level
53 // how many browser should be started simultaneous
54 concurrency: Infinity,
55 };
56
57 if (isDocker) {
58 // See https://hackernoon.com/running-karma-tests-with-headless-chrome-inside-docker-ae4aceb06ed3
59 cfg.browsers = ['ChromeHeadlessNoSandbox'],
60 cfg.customLaunchers = {
61 ChromeHeadlessNoSandbox: {
Kevin Lubick9c2b7cf2019-11-21 12:49:16 -050062 base: 'ChromeHeadless',
63 flags: [
Kevin Lubick556350d2018-10-12 15:21:17 -040064 // Without this flag, we see an error:
65 // Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
Kevin Lubick9c2b7cf2019-11-21 12:49:16 -050066 '--no-sandbox',
67 // may help tests be less flaky
68 // https://peter.sh/experiments/chromium-command-line-switches/#browser-test
69 '--browser-test',
70 // This can also help avoid crashes/timeouts:
71 // https://github.com/GoogleChrome/puppeteer/issues/1834
72 '--disable-dev-shm-usage',
73 ],
Kevin Lubick556350d2018-10-12 15:21:17 -040074 },
75 };
76 }
77
78 if (process.env.ASM_JS) {
79 console.log('asm.js is under test');
80 cfg.files = [
81 { pattern: 'npm-asmjs/bin/pathkit.js.mem', included:false, served:true},
82 'perf/perfReporter.js',
83 'npm-asmjs/bin/pathkit.js',
Kevin Lubickd2544352019-03-12 09:20:32 -040084 'tests/pathkitinit.js',
Kevin Lubick556350d2018-10-12 15:21:17 -040085 'perf/*.bench.js'
86 ];
87
88 cfg.proxies = {
89 '/pathkit/': '/base/npm-asmjs/bin/'
90 };
91 } else {
92 console.log('wasm is under test');
93 }
94
95 config.set(cfg);
96}