karma.conf.js 4.0 KB

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