karma.conf.js 3.9 KB

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