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/*.spec.js' 18 ], 19 20 proxies: { 21 '/assets/': '/base/tests/assets/', 22 '/canvaskit/': '/base/canvaskit/bin/', 23 }, 24 25 // test results reporter to use 26 // possible values: 'dots', 'progress' 27 // available reporters: https://npmjs.org/browse/keyword/karma-reporter 28 reporters: ['progress'], 29 30 // web server port 31 port: 4444, 32 33 // enable / disable colors in the output (reporters and logs) 34 colors: true, 35 36 // level of logging 37 // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 38 logLevel: config.LOG_INFO, 39 40 // enable / disable watching file and executing tests whenever any file changes 41 autoWatch: true, 42 43 browserDisconnectTimeout: 15000, 44 browserNoActivityTimeout: 15000, 45 46 // start these browsers 47 browsers: ['Chrome'], 48 49 // Continuous Integration mode 50 // if true, Karma captures browsers, runs the tests and exits 51 singleRun: false, 52 53 // Concurrency level 54 // how many browser should be started simultaneous 55 concurrency: Infinity, 56 }; 57 58 if (isDocker) { 59 // See https://hackernoon.com/running-karma-tests-with-headless-chrome-inside-docker-ae4aceb06ed3 60 cfg.browsers = ['ChromeHeadlessNoSandbox'], 61 cfg.customLaunchers = { 62 ChromeHeadlessNoSandbox: { 63 base: 'ChromeHeadless', 64 flags: [ 65 // Without this flag, we see an error: 66 // Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted 67 '--no-sandbox' 68 ], 69 }, 70 }; 71 } 72 73 config.set(cfg); 74} 75