blob: a2808a60b881a7d1386d93079cf420a6e1b1261f [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',
16 'perf/*.bench.js'
17 ],
18
19 proxies: {
20 '/pathkit/': '/base/npm-wasm/bin/'
21 },
22
23 // test results reporter to use
24 // possible values: 'dots', 'progress'
25 // available reporters: https://npmjs.org/browse/keyword/karma-reporter
26 reporters: ['dots'],
27
28 // web server port
29 port: 4444,
30
31 // enable / disable colors in the output (reporters and logs)
32 colors: true,
33
34 // level of logging
35 // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
36 logLevel: config.LOG_INFO,
37
38 // enable / disable watching file and executing tests whenever any file changes
39 autoWatch: true,
40
41 browserDisconnectTimeout: 10000,
42 browserNoActivityTimeout: 10000,
43
44 // start these browsers
45 browsers: ['Chrome'],
46
47 // Continuous Integration mode
48 // if true, Karma captures browsers, runs the tests and exits
49 singleRun: false,
50
51 // Concurrency level
52 // how many browser should be started simultaneous
53 concurrency: Infinity,
54 };
55
56 if (isDocker) {
57 // See https://hackernoon.com/running-karma-tests-with-headless-chrome-inside-docker-ae4aceb06ed3
58 cfg.browsers = ['ChromeHeadlessNoSandbox'],
59 cfg.customLaunchers = {
60 ChromeHeadlessNoSandbox: {
61 base: 'ChromeHeadless',
62 flags: [
63 // Without this flag, we see an error:
64 // Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
65 '--no-sandbox'
66 ],
67 },
68 };
69 }
70
71 if (process.env.ASM_JS) {
72 console.log('asm.js is under test');
73 cfg.files = [
74 { pattern: 'npm-asmjs/bin/pathkit.js.mem', included:false, served:true},
75 'perf/perfReporter.js',
76 'npm-asmjs/bin/pathkit.js',
77 'perf/*.bench.js'
78 ];
79
80 cfg.proxies = {
81 '/pathkit/': '/base/npm-asmjs/bin/'
82 };
83 } else {
84 console.log('wasm is under test');
85 }
86
87 config.set(cfg);
88}