karma.conf.js 2.7 KB

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