karma.bench.conf.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. const isDocker = require('is-docker')();
  2. module.exports = function(config) {
  3. // Set the default values to be what are needed when testing the
  4. // WebAssembly build locally.
  5. let cfg = {
  6. // frameworks to use
  7. // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
  8. frameworks: ['jasmine'],
  9. // list of files / patterns to load in the browser
  10. files: [
  11. { pattern: 'canvaskit/bin/canvaskit.wasm', included:false, served:true},
  12. { pattern: 'perf/assets/*', included:false, served:true},
  13. '../../modules/pathkit/perf/perfReporter.js',
  14. 'canvaskit/bin/canvaskit.js',
  15. 'tests/canvaskitinit.js',
  16. 'perf/*.bench.js'
  17. ],
  18. proxies: {
  19. '/canvaskit/': '/base/canvaskit/bin/',
  20. '/assets/': '/base/perf/assets/'
  21. },
  22. // test results reporter to use
  23. // possible values: 'dots', 'progress'
  24. // available reporters: https://npmjs.org/browse/keyword/karma-reporter
  25. reporters: ['progress'],
  26. // web server port
  27. port: 4444,
  28. // enable / disable colors in the output (reporters and logs)
  29. colors: true,
  30. // level of logging
  31. // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
  32. logLevel: config.LOG_INFO,
  33. // enable / disable watching file and executing tests whenever any file changes
  34. autoWatch: true,
  35. browserDisconnectTimeout: 20000,
  36. browserNoActivityTimeout: 20000,
  37. // start these browsers
  38. browsers: ['Chrome'],
  39. // Continuous Integration mode
  40. // if true, Karma captures browsers, runs the tests and exits
  41. singleRun: false,
  42. // Concurrency level
  43. // how many browser should be started simultaneous
  44. concurrency: Infinity,
  45. };
  46. if (isDocker) {
  47. // See https://hackernoon.com/running-karma-tests-with-headless-chrome-inside-docker-ae4aceb06ed3
  48. cfg.browsers = ['ChromeHeadlessNoSandbox'],
  49. cfg.customLaunchers = {
  50. ChromeHeadlessNoSandbox: {
  51. base: 'ChromeHeadless',
  52. flags: [
  53. // Without this flag, we see an error:
  54. // Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
  55. '--no-sandbox'
  56. ],
  57. },
  58. };
  59. }
  60. if (process.env.ASM_JS) {
  61. console.log('asm.js is under test');
  62. cfg.files = [
  63. { pattern: 'npm-asmjs/bin/pathkit.js.mem', included:false, served:true},
  64. 'perf/perfReporter.js',
  65. 'npm-asmjs/bin/pathkit.js',
  66. 'perf/*.bench.js'
  67. ];
  68. cfg.proxies = {
  69. '/pathkit/': '/base/npm-asmjs/bin/'
  70. };
  71. } else {
  72. console.log('wasm is under test');
  73. }
  74. config.set(cfg);
  75. }