You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // Karma configuration
  2. const karmaCommon = require('./karma.conf.common.cjs')
  3. let chromeBin = 'ChromeHeadless'
  4. if (process.platform === 'linux') {
  5. // We need to choose either Chrome or Chromium.
  6. // Canary is not available on linux.
  7. // If we do not find Chromium then we can deduce that
  8. // either Chrome is installed or there is no Chrome variant at all,
  9. // in which case karma-chrome-launcher will output an error.
  10. // If `which` finds nothing it will throw an error.
  11. const { execSync } = require('child_process')
  12. try {
  13. if (execSync('which chromium-browser')) chromeBin = 'ChromiumHeadless'
  14. } catch (e) {}
  15. }
  16. module.exports = function (config) {
  17. config.set(
  18. Object.assign(karmaCommon(config), {
  19. files: [
  20. 'spec/RAFPlugin.js',
  21. {
  22. pattern: 'spec/fixtures/fixture.css',
  23. included: false,
  24. served: true
  25. },
  26. {
  27. pattern: 'spec/fixtures/pixel.png',
  28. included: false,
  29. served: true
  30. },
  31. {
  32. pattern: 'src/**/*.js',
  33. included: false,
  34. served: true,
  35. type: 'modules'
  36. },
  37. {
  38. pattern: 'spec/helpers.js',
  39. included: false,
  40. served: true,
  41. type: 'module'
  42. },
  43. {
  44. pattern: 'spec/setupBrowser.js',
  45. included: true,
  46. type: 'module'
  47. },
  48. {
  49. pattern: 'spec/spec/*/**/*.js',
  50. included: true,
  51. type: 'module'
  52. }
  53. ],
  54. // preprocess matching files before serving them to the browser
  55. // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
  56. preprocessors: {
  57. 'src/**/*.js': ['coverage']
  58. },
  59. // test results reporter to use
  60. // possible values: 'dots', 'progress'
  61. // available reporters: https://npmjs.org/browse/keyword/karma-reporter
  62. reporters: ['progress', 'coverage'],
  63. coverageReporter: {
  64. // Specify a reporter type.
  65. type: 'lcov',
  66. dir: 'coverage/',
  67. subdir: function (browser) {
  68. // normalization process to keep a consistent browser name accross different OS
  69. return browser.toLowerCase().split(/[ /-]/)[0] // output the results into: './coverage/firefox/'
  70. },
  71. instrumenterOptions: {
  72. istanbul: {
  73. esModules: true
  74. }
  75. }
  76. },
  77. // start these browsers
  78. // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
  79. browsers: [chromeBin, 'FirefoxHeadless']
  80. })
  81. )
  82. }