Kevin Lubick | f14a3c0 | 2018-08-22 09:35:32 -0400 | [diff] [blame] | 1 | const isDocker = require('is-docker')(); |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 2 | |
Kevin Lubick | f14a3c0 | 2018-08-22 09:35:32 -0400 | [diff] [blame] | 3 | module.exports = function(config) { |
| 4 | // Set the default values to be what are needed when testing the |
| 5 | // WebAssembly build locally. |
| 6 | let cfg = { |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 7 | // frameworks to use |
| 8 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter |
| 9 | frameworks: ['jasmine'], |
| 10 | |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 11 | // 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 Lubick | a0ba612 | 2018-08-15 13:45:28 -0400 | [diff] [blame] | 15 | 'tests/testReporter.js', |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 16 | 'npm-wasm/bin/test/pathkit.js', |
| 17 | 'tests/*.spec.js' |
| 18 | ], |
| 19 | |
Kevin Lubick | 97d6d98 | 2018-08-10 15:53:16 -0400 | [diff] [blame] | 20 | proxies: { |
Kevin Lubick | 556350d | 2018-10-12 15:21:17 -0400 | [diff] [blame] | 21 | '/pathkit/': '/base/npm-wasm/bin/test/' |
Kevin Lubick | 97d6d98 | 2018-08-10 15:53:16 -0400 | [diff] [blame] | 22 | }, |
| 23 | |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 24 | // test results reporter to use |
| 25 | // possible values: 'dots', 'progress' |
| 26 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter |
| 27 | reporters: ['progress'], |
| 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 Lubick | c6c48aa | 2018-08-17 15:00:43 -0400 | [diff] [blame] | 42 | browserDisconnectTimeout: 15000, |
| 43 | browserNoActivityTimeout: 15000, |
| 44 | |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 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, |
Kevin Lubick | f14a3c0 | 2018-08-22 09:35:32 -0400 | [diff] [blame] | 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: { |
| 62 | base: 'ChromeHeadless', |
| 63 | flags: [ |
| 64 | // 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 |
| 66 | '--no-sandbox' |
| 67 | ], |
| 68 | }, |
| 69 | }; |
| 70 | } |
| 71 | |
| 72 | if (process.env.ASM_JS) { |
| 73 | console.log('asm.js is under test'); |
| 74 | cfg.files = [ |
| 75 | { pattern: 'npm-asmjs/bin/test/pathkit.js.mem', included:false, served:true}, |
| 76 | { pattern: 'tests/*.json', included:false, served:true}, |
| 77 | 'tests/testReporter.js', |
| 78 | 'npm-asmjs/bin/test/pathkit.js', |
| 79 | 'tests/*.spec.js' |
| 80 | ]; |
| 81 | |
| 82 | cfg.proxies = { |
Kevin Lubick | 556350d | 2018-10-12 15:21:17 -0400 | [diff] [blame] | 83 | '/pathkit/': '/base/npm-asmjs/bin/test/' |
Kevin Lubick | f14a3c0 | 2018-08-22 09:35:32 -0400 | [diff] [blame] | 84 | }; |
| 85 | } else { |
| 86 | console.log('wasm is under test'); |
| 87 | } |
| 88 | |
| 89 | config.set(cfg); |
Kevin Lubick | 92c9171 | 2018-08-09 10:00:02 -0400 | [diff] [blame] | 90 | } |