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