karma.conf.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. var common = require('./webpack.common.js')
  2. module.exports = function (config) {
  3. 'use strict'
  4. config.set({
  5. // base path that will be used to resolve all patterns (eg. files, exclude)
  6. basePath: '',
  7. // frameworks to use
  8. // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
  9. frameworks: ['mocha', 'chai'],
  10. // list of files to exclude
  11. exclude: [],
  12. files: [{
  13. pattern: 'src/**/*.ts',
  14. included: false
  15. }, {
  16. pattern: 'test/**/*.ts',
  17. included: true
  18. }, {
  19. pattern: 'test/data/*.xml',
  20. included: true
  21. }, {
  22. pattern: 'test/data/*.mxl.base64',
  23. included: true
  24. }, {
  25. pattern: 'test/data/*.mxl',
  26. included: false,
  27. watched: false,
  28. served: true
  29. }],
  30. // preprocess matching files before serving them to the browser
  31. // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
  32. preprocessors: {
  33. 'test/data/*.xml': ['xml2js'],
  34. 'test/data/*.mxl.base64': ['base64-to-js'],
  35. // add webpack as preprocessor
  36. 'src/**/*.ts': ['webpack'],
  37. 'test/**/*.ts': ['webpack']
  38. },
  39. webpack: {
  40. // karma watches the test entry points
  41. // (you don't need to specify the entry option)
  42. // webpack watches dependencies
  43. // copy parts of webpack configuration to use minimal effort here
  44. devtool: 'cheap-module-eval-source-map',
  45. mode: 'production',
  46. module: {
  47. rules: common.module.rules
  48. },
  49. resolve: common.resolve
  50. },
  51. webpackMiddleware: {
  52. // webpack-dev-middleware configuration
  53. // i. e.
  54. noInfo: true
  55. },
  56. // Required for Firefox and Chorme to work
  57. // see https://github.com/webpack-contrib/karma-webpack/issues/188
  58. mime: {
  59. 'text/x-typescript': ['ts', 'tsx']
  60. },
  61. // test results reporter to use
  62. // possible values: 'dots', 'progress'
  63. // available reporters: https://npmjs.org/browse/keyword/karma-reporter
  64. reporters: ['mocha'],
  65. // web server port
  66. port: 9876,
  67. // enable / disable colors in the output (reporters and logs)
  68. colors: true,
  69. // level of logging
  70. // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
  71. logLevel: config.LOG_ERROR,
  72. client: {
  73. captureConsole: true
  74. },
  75. // enable / disable watching file and executing tests whenever any file changes
  76. autoWatch: false,
  77. // start these browsers
  78. browsers: [process.env.CI ? 'ChromeHeadlessNoSandbox' : 'ChromeHeadless'],
  79. // For security reasons, Google Chrome is unable to provide sandboxing
  80. // when it is running in container-based environments (e.g. CI).
  81. customLaunchers: {
  82. ChromeHeadlessNoSandbox: {
  83. base: 'ChromeHeadless',
  84. flags: ['--no-sandbox']
  85. }
  86. },
  87. // Continuous Integration mode
  88. // if true, Karma captures browsers, runs the tests and exits
  89. singleRun: true,
  90. // Concurrency level
  91. // how many browser should be started simultaneous
  92. concurrency: Infinity
  93. })
  94. }