karma.conf.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. const path = require('path')
  2. module.exports = function (config) {
  3. config.set({
  4. customLaunchers: {
  5. ChromeCustom: {
  6. base: 'ChromeHeadless',
  7. // We must disable the Chrome sandbox when running Chrome inside Docker
  8. // (Chrome's sandbox needs more permissions than Docker allows by
  9. // default)
  10. flags: ['--no-sandbox']
  11. }
  12. },
  13. browsers: ['ChromeCustom'],
  14. files: [
  15. 'test/unit_frontend/js/bootstrap.js',
  16. // Angular must be loaded before requirejs to set up angular global
  17. 'public/js/libs/angular-1.6.4.min.js',
  18. 'public/js/libs/angular-mocks.js',
  19. 'public/js/libs/jquery-1.11.1.min.js',
  20. // Set up requirejs
  21. 'test/unit_frontend/js/test-main.js',
  22. // Include source & test files, but don't "include" them as requirejs
  23. // handles this for us
  24. { pattern: 'public/js/**/*.js', included: false },
  25. { pattern: 'test/unit_frontend/js/**/*.js', included: false },
  26. // Include ES test files
  27. 'test/unit_frontend/es/**/*.js'
  28. ],
  29. preprocessors: {
  30. // Run ES test files through webpack (which will then include source
  31. // files in bundle)
  32. 'test/unit_frontend/es/**/*.js': ['webpack']
  33. },
  34. frameworks: ['requirejs', 'mocha', 'chai-sinon'],
  35. // Configure webpack in the tests
  36. webpack: {
  37. resolve: {
  38. alias: {
  39. // Alias Src in import pathnames to public/es
  40. // Cuts down on the amount of ../../ etc
  41. Src: path.join(__dirname, 'public/es/')
  42. }
  43. }
  44. },
  45. // Configure the webpack dev server used to serve test files
  46. webpackMiddleware: {
  47. // Disable noisy CLI output
  48. stats: 'errors-only'
  49. },
  50. plugins: [
  51. require('karma-chrome-launcher'),
  52. require('karma-requirejs'),
  53. require('karma-mocha'),
  54. require('karma-chai-sinon'),
  55. require('karma-webpack'),
  56. require('karma-mocha-reporter')
  57. ],
  58. reporters: ['mocha']
  59. });
  60. }