karma.conf.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. reporters: ['tap'],
  36. // Configure webpack in the tests
  37. webpack: {
  38. resolve: {
  39. alias: {
  40. // Alias Src in import pathnames to public/es
  41. // Cuts down on the amount of ../../ etc
  42. Src: path.join(__dirname, 'public/es/')
  43. }
  44. }
  45. },
  46. // Configure the webpack dev server used to serve test files
  47. webpackMiddleware: {
  48. // Disable noisy CLI output
  49. stats: 'errors-only'
  50. },
  51. plugins: [
  52. require('karma-chrome-launcher'),
  53. require('karma-requirejs'),
  54. require('karma-mocha'),
  55. require('karma-chai-sinon'),
  56. require('karma-webpack'),
  57. require('karma-mocha-reporter')
  58. ],
  59. reporters: ['mocha']
  60. });
  61. }