| Kevin Lubick | f2a146c | 2018-10-17 14:59:35 -0400 | [diff] [blame] | 1 | const isDocker = require('is-docker')(); |
| 2 | |
| 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 = { |
| 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: 'canvaskit/bin/canvaskit.wasm', included:false, served:true}, |
| 14 | { pattern: 'perf/assets/*', included:false, served:true}, |
| 15 | '../../modules/pathkit/perf/perfReporter.js', |
| 16 | 'canvaskit/bin/canvaskit.js', |
| Kevin Lubick | cb4eb61 | 2019-03-06 09:30:44 -0500 | [diff] [blame] | 17 | 'tests/canvaskitinit.js', |
| Nathaniel Nifong | 1bedbeb | 2020-05-04 16:46:17 -0400 | [diff] [blame] | 18 | 'tests/util.js', |
| Kevin Lubick | f2a146c | 2018-10-17 14:59:35 -0400 | [diff] [blame] | 19 | 'perf/*.bench.js' |
| 20 | ], |
| 21 | |
| 22 | proxies: { |
| 23 | '/canvaskit/': '/base/canvaskit/bin/', |
| 24 | '/assets/': '/base/perf/assets/' |
| 25 | }, |
| 26 | |
| 27 | // test results reporter to use |
| 28 | // possible values: 'dots', 'progress' |
| 29 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter |
| 30 | reporters: ['progress'], |
| 31 | |
| 32 | // web server port |
| 33 | port: 4444, |
| 34 | |
| 35 | // enable / disable colors in the output (reporters and logs) |
| 36 | colors: true, |
| 37 | |
| 38 | // level of logging |
| 39 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG |
| 40 | logLevel: config.LOG_INFO, |
| 41 | |
| 42 | // enable / disable watching file and executing tests whenever any file changes |
| 43 | autoWatch: true, |
| 44 | |
| Kevin Lubick | ec841f7 | 2019-03-07 08:43:11 -0500 | [diff] [blame] | 45 | browserDisconnectTimeout: 20000, |
| 46 | browserNoActivityTimeout: 20000, |
| Kevin Lubick | f2a146c | 2018-10-17 14:59:35 -0400 | [diff] [blame] | 47 | |
| 48 | // start these browsers |
| 49 | browsers: ['Chrome'], |
| 50 | |
| 51 | // Continuous Integration mode |
| 52 | // if true, Karma captures browsers, runs the tests and exits |
| 53 | singleRun: false, |
| 54 | |
| 55 | // Concurrency level |
| 56 | // how many browser should be started simultaneous |
| 57 | concurrency: Infinity, |
| 58 | }; |
| 59 | |
| 60 | if (isDocker) { |
| 61 | // See https://hackernoon.com/running-karma-tests-with-headless-chrome-inside-docker-ae4aceb06ed3 |
| 62 | cfg.browsers = ['ChromeHeadlessNoSandbox'], |
| 63 | cfg.customLaunchers = { |
| 64 | ChromeHeadlessNoSandbox: { |
| Kevin Lubick | 9c2b7cf | 2019-11-21 12:49:16 -0500 | [diff] [blame] | 65 | base: 'ChromeHeadless', |
| 66 | flags: [ |
| Kevin Lubick | f2a146c | 2018-10-17 14:59:35 -0400 | [diff] [blame] | 67 | // Without this flag, we see an error: |
| 68 | // Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted |
| Kevin Lubick | 9c2b7cf | 2019-11-21 12:49:16 -0500 | [diff] [blame] | 69 | '--no-sandbox', |
| 70 | // may help tests be less flaky |
| 71 | // https://peter.sh/experiments/chromium-command-line-switches/#browser-test |
| 72 | '--browser-test', |
| 73 | // This can also help avoid crashes/timeouts: |
| 74 | // https://github.com/GoogleChrome/puppeteer/issues/1834 |
| 75 | '--disable-dev-shm-usage', |
| 76 | ], |
| Kevin Lubick | f2a146c | 2018-10-17 14:59:35 -0400 | [diff] [blame] | 77 | }, |
| 78 | }; |
| 79 | } |
| 80 | |
| 81 | if (process.env.ASM_JS) { |
| 82 | console.log('asm.js is under test'); |
| 83 | cfg.files = [ |
| 84 | { pattern: 'npm-asmjs/bin/pathkit.js.mem', included:false, served:true}, |
| 85 | 'perf/perfReporter.js', |
| 86 | 'npm-asmjs/bin/pathkit.js', |
| 87 | 'perf/*.bench.js' |
| 88 | ]; |
| 89 | |
| 90 | cfg.proxies = { |
| 91 | '/pathkit/': '/base/npm-asmjs/bin/' |
| 92 | }; |
| 93 | } else { |
| 94 | console.log('wasm is under test'); |
| 95 | } |
| 96 | |
| 97 | config.set(cfg); |
| 98 | } |