blob: 47ff2d25ee4cec1ae46771c1e27c9aff24fcc6c3 [file] [log] [blame]
Kevin Lubickf14a3c02018-08-22 09:35:32 -04001const isDocker = require('is-docker')();
Kevin Lubick92c91712018-08-09 10:00:02 -04002
Kevin Lubickf14a3c02018-08-22 09:35:32 -04003module.exports = function(config) {
4 // Set the default values to be what are needed when testing the
5 // WebAssembly build locally.
6 let cfg = {
Kevin Lubick92c91712018-08-09 10:00:02 -04007 // frameworks to use
8 // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
9 frameworks: ['jasmine'],
10
Kevin Lubick92c91712018-08-09 10:00:02 -040011 // list of files / patterns to load in the browser
12 files: [
13 { pattern: 'npm-wasm/bin/test/pathkit.wasm', included:false, served:true},
14 { pattern: 'tests/*.json', included:false, served:true},
Kevin Lubicka0ba6122018-08-15 13:45:28 -040015 'tests/testReporter.js',
Kevin Lubick92c91712018-08-09 10:00:02 -040016 'npm-wasm/bin/test/pathkit.js',
Kevin Lubickd2544352019-03-12 09:20:32 -040017 'tests/pathkitinit.js',
Kevin Lubick92c91712018-08-09 10:00:02 -040018 'tests/*.spec.js'
19 ],
20
Kevin Lubick97d6d982018-08-10 15:53:16 -040021 proxies: {
Kevin Lubick556350d2018-10-12 15:21:17 -040022 '/pathkit/': '/base/npm-wasm/bin/test/'
Kevin Lubick97d6d982018-08-10 15:53:16 -040023 },
24
Kevin Lubick92c91712018-08-09 10:00:02 -040025 // test results reporter to use
26 // possible values: 'dots', 'progress'
27 // available reporters: https://npmjs.org/browse/keyword/karma-reporter
28 reporters: ['progress'],
29
30 // web server port
31 port: 4444,
32
33 // enable / disable colors in the output (reporters and logs)
34 colors: true,
35
36 // level of logging
37 // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
38 logLevel: config.LOG_INFO,
39
40 // enable / disable watching file and executing tests whenever any file changes
41 autoWatch: true,
42
Kevin Lubickd2544352019-03-12 09:20:32 -040043 browserDisconnectTimeout: 20000,
44 browserNoActivityTimeout: 20000,
Kevin Lubickc6c48aa2018-08-17 15:00:43 -040045
Kevin Lubick92c91712018-08-09 10:00:02 -040046 // start these browsers
47 browsers: ['Chrome'],
48
49 // Continuous Integration mode
50 // if true, Karma captures browsers, runs the tests and exits
51 singleRun: false,
52
53 // Concurrency level
54 // how many browser should be started simultaneous
55 concurrency: Infinity,
Kevin Lubickf14a3c02018-08-22 09:35:32 -040056 };
57
58 if (isDocker) {
59 // See https://hackernoon.com/running-karma-tests-with-headless-chrome-inside-docker-ae4aceb06ed3
60 cfg.browsers = ['ChromeHeadlessNoSandbox'],
61 cfg.customLaunchers = {
62 ChromeHeadlessNoSandbox: {
63 base: 'ChromeHeadless',
64 flags: [
65 // Without this flag, we see an error:
66 // Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
67 '--no-sandbox'
68 ],
69 },
70 };
71 }
72
73 if (process.env.ASM_JS) {
74 console.log('asm.js is under test');
75 cfg.files = [
76 { pattern: 'npm-asmjs/bin/test/pathkit.js.mem', included:false, served:true},
77 { pattern: 'tests/*.json', included:false, served:true},
78 'tests/testReporter.js',
79 'npm-asmjs/bin/test/pathkit.js',
Kevin Lubickd2544352019-03-12 09:20:32 -040080 'tests/pathkitinit.js',
Kevin Lubickf14a3c02018-08-22 09:35:32 -040081 'tests/*.spec.js'
82 ];
83
84 cfg.proxies = {
Kevin Lubick556350d2018-10-12 15:21:17 -040085 '/pathkit/': '/base/npm-asmjs/bin/test/'
Kevin Lubickf14a3c02018-08-22 09:35:32 -040086 };
87 } else {
88 console.log('wasm is under test');
89 }
90
91 config.set(cfg);
Kevin Lubick92c91712018-08-09 10:00:02 -040092}