2018-10-16 14:15:01 +00:00
|
|
|
const isDocker = require('is-docker')();
|
|
|
|
|
|
|
|
module.exports = function(config) {
|
|
|
|
// Set the default values to be what are needed when testing the
|
|
|
|
// WebAssembly build locally.
|
|
|
|
let cfg = {
|
|
|
|
// frameworks to use
|
|
|
|
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
|
|
|
frameworks: ['jasmine'],
|
|
|
|
|
|
|
|
// list of files / patterns to load in the browser
|
|
|
|
files: [
|
2021-12-06 14:22:39 +00:00
|
|
|
{ pattern: 'build/canvaskit.wasm', included:false, served:true},
|
2018-12-03 17:31:04 +00:00
|
|
|
{ pattern: 'tests/assets/*', included:false, served:true},
|
2020-12-14 14:43:13 +00:00
|
|
|
'tests/testReporter.js',
|
2021-12-06 14:22:39 +00:00
|
|
|
'build/canvaskit.js',
|
2019-03-06 14:30:44 +00:00
|
|
|
'tests/canvaskitinit.js',
|
2019-02-22 15:04:06 +00:00
|
|
|
'tests/util.js',
|
2018-10-16 14:15:01 +00:00
|
|
|
'tests/*.spec.js'
|
|
|
|
],
|
|
|
|
|
|
|
|
proxies: {
|
2018-12-03 17:31:04 +00:00
|
|
|
'/assets/': '/base/tests/assets/',
|
2021-12-06 14:22:39 +00:00
|
|
|
'/build/': '/base/build/',
|
2018-10-16 14:15:01 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// test results reporter to use
|
|
|
|
// possible values: 'dots', 'progress'
|
|
|
|
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
|
|
|
reporters: ['progress'],
|
|
|
|
|
|
|
|
// web server port
|
|
|
|
port: 4444,
|
|
|
|
|
|
|
|
// enable / disable colors in the output (reporters and logs)
|
|
|
|
colors: true,
|
|
|
|
|
|
|
|
// level of logging
|
|
|
|
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
|
|
|
logLevel: config.LOG_INFO,
|
|
|
|
|
|
|
|
// enable / disable watching file and executing tests whenever any file changes
|
|
|
|
autoWatch: true,
|
|
|
|
|
2019-03-07 13:43:11 +00:00
|
|
|
browserDisconnectTimeout: 20000,
|
|
|
|
browserNoActivityTimeout: 20000,
|
2018-10-16 14:15:01 +00:00
|
|
|
|
|
|
|
// start these browsers
|
|
|
|
browsers: ['Chrome'],
|
|
|
|
|
|
|
|
// Continuous Integration mode
|
|
|
|
// if true, Karma captures browsers, runs the tests and exits
|
|
|
|
singleRun: false,
|
|
|
|
|
|
|
|
// Concurrency level
|
|
|
|
// how many browser should be started simultaneous
|
|
|
|
concurrency: Infinity,
|
|
|
|
};
|
|
|
|
|
2020-05-20 21:24:30 +00:00
|
|
|
if (isDocker || config.headless) {
|
2018-10-16 14:15:01 +00:00
|
|
|
// See https://hackernoon.com/running-karma-tests-with-headless-chrome-inside-docker-ae4aceb06ed3
|
|
|
|
cfg.browsers = ['ChromeHeadlessNoSandbox'],
|
|
|
|
cfg.customLaunchers = {
|
|
|
|
ChromeHeadlessNoSandbox: {
|
2019-11-21 17:49:16 +00:00
|
|
|
base: 'ChromeHeadless',
|
|
|
|
flags: [
|
2018-10-16 14:15:01 +00:00
|
|
|
// Without this flag, we see an error:
|
|
|
|
// Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
|
2019-11-21 17:49:16 +00:00
|
|
|
'--no-sandbox',
|
|
|
|
// may help tests be less flaky
|
|
|
|
// https://peter.sh/experiments/chromium-command-line-switches/#browser-test
|
|
|
|
'--browser-test',
|
|
|
|
// This can also help avoid crashes/timeouts:
|
|
|
|
// https://github.com/GoogleChrome/puppeteer/issues/1834
|
|
|
|
'--disable-dev-shm-usage',
|
|
|
|
],
|
2018-10-16 14:15:01 +00:00
|
|
|
},
|
|
|
|
};
|
2020-05-29 15:06:19 +00:00
|
|
|
} else {
|
|
|
|
// Extra options that should only be applied locally
|
|
|
|
|
|
|
|
// Measure test coverage and write output to coverage/ directory
|
|
|
|
cfg.reporters.push('coverage');
|
|
|
|
cfg.preprocessors = {
|
|
|
|
// Measure test coverage of these source files
|
|
|
|
// Since this file is a combination of our code, and emscripten's glue,
|
|
|
|
// we'll never see 100% coverage, but this lets us measure improvements.
|
|
|
|
'canvaskit/bin/canvaskit.js': ['coverage'],
|
|
|
|
};
|
2018-10-16 14:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
config.set(cfg);
|
|
|
|
}
|