1// This is the legacy (non-Bazel) test setup. 2const isDocker = require('is-docker')(); 3 4module.exports = function(config) { 5 // Set the default values to be what are needed when testing the 6 // WebAssembly build locally. 7 let cfg = { 8 // frameworks to use 9 // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 10 frameworks: ['jasmine'], 11 12 // list of files / patterns to load in the browser 13 files: [ 14 { pattern: 'build/canvaskit.wasm', included:false, served:true}, 15 { pattern: 'tests/assets/*', included:false, served:true}, 16 'build/canvaskit.js', 17 'tests/legacy_init.js', 18 'tests/util.js', 19 'tests/legacy_test_reporter.js', 20 'tests/*_test.js' 21 ], 22 23 proxies: { 24 '/assets/': '/base/tests/assets/', 25 '/build/': '/base/build/', 26 }, 27 28 // test results reporter to use 29 // possible values: 'dots', 'progress' 30 // available reporters: https://npmjs.org/browse/keyword/karma-reporter 31 reporters: ['progress'], 32 33 // web server port 34 port: 4444, 35 36 // enable / disable colors in the output (reporters and logs) 37 colors: true, 38 39 // level of logging 40 // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 41 logLevel: config.LOG_INFO, 42 43 // enable / disable watching file and executing tests whenever any file changes 44 autoWatch: true, 45 46 browserDisconnectTimeout: 20000, 47 browserNoActivityTimeout: 20000, 48 49 // start these browsers 50 browsers: ['Chrome'], 51 52 // Continuous Integration mode 53 // if true, Karma captures browsers, runs the tests and exits 54 singleRun: false, 55 56 // Concurrency level 57 // how many browser should be started simultaneous 58 concurrency: Infinity, 59 }; 60 61 if (isDocker || config.headless) { 62 // See https://hackernoon.com/running-karma-tests-with-headless-chrome-inside-docker-ae4aceb06ed3 63 cfg.browsers = ['ChromeHeadlessNoSandbox'], 64 cfg.customLaunchers = { 65 ChromeHeadlessNoSandbox: { 66 base: 'ChromeHeadless', 67 flags: [ 68 // Without this flag, we see an error: 69 // Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted 70 '--no-sandbox', 71 // may help tests be less flaky 72 // https://peter.sh/experiments/chromium-command-line-switches/#browser-test 73 '--browser-test', 74 // This can also help avoid crashes/timeouts: 75 // https://github.com/GoogleChrome/puppeteer/issues/1834 76 '--disable-dev-shm-usage', 77 ], 78 }, 79 }; 80 } else { 81 // Extra options that should only be applied locally 82 83 // Measure test coverage and write output to coverage/ directory 84 cfg.reporters.push('coverage'); 85 cfg.preprocessors = { 86 // Measure test coverage of these source files 87 // Since this file is a combination of our code, and emscripten's glue, 88 // we'll never see 100% coverage, but this lets us measure improvements. 89 'canvaskit/bin/canvaskit.js': ['coverage'], 90 }; 91 } 92 93 config.set(cfg); 94} 95