karma.conf.js 4.3 KB

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