karma.conf.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. {
  14. pattern: 'test/**/*.ts',
  15. included: true
  16. }, {
  17. pattern: 'test/data/*.xml',
  18. included: true
  19. }, {
  20. pattern: 'test/data/*.mxl.base64',
  21. included: true
  22. }, {
  23. pattern: 'test/data/*.mxl',
  24. included: false,
  25. watched: false,
  26. served: true
  27. }],
  28. // preprocess matching files before serving them to the browser
  29. // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
  30. preprocessors: {
  31. 'test/data/*.xml': ['xml2js'],
  32. 'test/data/*.mxl.base64': ['base64-to-js'],
  33. // add webpack as preprocessor
  34. 'test/**/*.ts': ['webpack']
  35. },
  36. webpack: {
  37. // karma watches the test entry points
  38. // (you don't need to specify the entry option)
  39. // webpack watches dependencies
  40. // copy parts of webpack configuration to use minimal effort here
  41. devtool: process.env.CI ? false : 'inline-source-map',
  42. mode: process.env.CI ? 'production' : 'development',
  43. module: {
  44. rules: common.module.rules
  45. },
  46. resolve: common.resolve
  47. },
  48. // Required for Firefox and Chrome to work
  49. // see https://github.com/webpack-contrib/karma-webpack/issues/188
  50. mime: {
  51. 'text/x-typescript': ['ts']
  52. },
  53. // test results reporter to use
  54. // possible values: 'dots', 'progress'
  55. // available reporters: https://npmjs.org/browse/keyword/karma-reporter
  56. reporters: ['mocha'],
  57. // web server port
  58. port: 9876,
  59. // timeout in ms:
  60. browserNoActivityTimeout: 100000, // default 10000
  61. browserDisconnectTimeout: 10000, // default 2000
  62. browserDisconnectTolerance: 1, // default 0
  63. captureTimeout: 60000,
  64. // enable / disable colors in the output (reporters and logs)
  65. colors: true,
  66. // level of logging
  67. // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
  68. logLevel: config.LOG_INFO,
  69. client: {
  70. captureConsole: true,
  71. mocha: {
  72. timeout: process.env.timeout || 6000
  73. }
  74. },
  75. // enable / disable watching file and executing tests whenever any file changes
  76. autoWatch: false,
  77. // start these browsers
  78. browsers: ['ChromeHeadlessNoSandbox'],
  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. '--disable-web-security']
  86. },
  87. ChromeNoSecurity: {
  88. base: 'Chrome',
  89. flags: ['--disable-web-security']
  90. }
  91. },
  92. // Continuous Integration mode
  93. // if true, Karma captures browsers, runs the tests and exits
  94. singleRun: true,
  95. // Concurrency level
  96. // how many browser should be started simultaneous
  97. concurrency: Infinity
  98. })
  99. }