blob: a5eb509975ca587bfb5f5c7b392b50da2b3e4a43 [file] [log] [blame]
Kevin Lubickf2a146c2018-10-17 14:59:35 -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: '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 Lubickcb4eb612019-03-06 09:30:44 -050017 'tests/canvaskitinit.js',
Nathaniel Nifong1bedbeb2020-05-04 16:46:17 -040018 'tests/util.js',
Kevin Lubickf2a146c2018-10-17 14:59:35 -040019 '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 Lubickec841f72019-03-07 08:43:11 -050045 browserDisconnectTimeout: 20000,
46 browserNoActivityTimeout: 20000,
Kevin Lubickf2a146c2018-10-17 14:59:35 -040047
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 Lubick9c2b7cf2019-11-21 12:49:16 -050065 base: 'ChromeHeadless',
66 flags: [
Kevin Lubickf2a146c2018-10-17 14:59:35 -040067 // 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 Lubick9c2b7cf2019-11-21 12:49:16 -050069 '--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 Lubickf2a146c2018-10-17 14:59:35 -040077 },
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}