karma.conf.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. module: {
  46. loaders: common.module.loaders
  47. },
  48. resolve: common.resolve
  49. },
  50. webpackMiddleware: {
  51. // webpack-dev-middleware configuration
  52. // i. e.
  53. noInfo: true
  54. },
  55. // Required for Firefox and Chorme to work
  56. // see https://github.com/webpack-contrib/karma-webpack/issues/188
  57. mime: {
  58. 'text/x-typescript': ['ts', 'tsx']
  59. },
  60. // test results reporter to use
  61. // possible values: 'dots', 'progress'
  62. // available reporters: https://npmjs.org/browse/keyword/karma-reporter
  63. reporters: ['mocha'],
  64. // web server port
  65. port: 9876,
  66. // timeout in ms:
  67. browserNoActivityTimeout: 100000,
  68. captureTimeout: 60000,
  69. // enable / disable colors in the output (reporters and logs)
  70. colors: true,
  71. // level of logging
  72. // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
  73. logLevel: config.LOG_ERROR,
  74. client: {
  75. captureConsole: true
  76. },
  77. // enable / disable watching file and executing tests whenever any file changes
  78. autoWatch: false,
  79. // start these browsers
  80. browsers: [process.env.CI ? 'ChromeHeadlessNoSandbox' : 'ChromeHeadless'],
  81. // For security reasons, Google Chrome is unable to provide sandboxing
  82. // when it is running in container-based environments (e.g. CI).
  83. customLaunchers: {
  84. ChromeHeadlessNoSandbox: {
  85. base: 'ChromeHeadless',
  86. flags: ['--no-sandbox']
  87. }
  88. },
  89. // Continuous Integration mode
  90. // if true, Karma captures browsers, runs the tests and exits
  91. singleRun: true,
  92. // Concurrency level
  93. // how many browser should be started simultaneous
  94. concurrency: Infinity
  95. })
  96. }