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: 'tests/assets/*', included:false, served:true}, 15 '../../modules/pathkit/tests/testReporter.js', 16 'canvaskit/bin/canvaskit.js', 17 'tests/canvaskitinit.js', 18 'tests/util.js', 19 'tests/*.spec.js' 20 ], 21 22 proxies: { 23 '/assets/': '/base/tests/assets/', 24 '/canvaskit/': '/base/canvaskit/bin/', 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 45 browserDisconnectTimeout: 20000, 46 browserNoActivityTimeout: 20000, 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: { 65 base: 'ChromeHeadless', 66 flags: [ 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 69 '--no-sandbox' 70 ], 71 }, 72 }; 73 } 74 75 config.set(cfg); 76} 77