karma.conf.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. var webpackConfig = require("./webpack.test.conf.js");
  2. var path = require('path');
  3. module.exports = function karmaConfig(config) {
  4. var configuration = {
  5. // base path that will be used to resolve all patterns (eg. files, exclude)
  6. basePath: '../dist/',
  7. // frameworks to use
  8. // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
  9. frameworks: ['jasmine'],
  10. // list of files / patterns to load in the browser
  11. files: [
  12. require.resolve('plusnew'),
  13. '../configs/karma/globalEnzyme.ts',
  14. '../src/**/*.test.tsx',
  15. '../src/**/*.test.ts',
  16. { pattern: '**/*', watched: true, included: false, served: true, nocache: false }
  17. ],
  18. // webpack: webpackConfig,
  19. // list of files to exclude
  20. exclude: [],
  21. // // preprocess matching files before serving them to the browser
  22. // // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
  23. preprocessors:
  24. {
  25. '../configs/karma/globalEnzyme.ts': ['webpack'],
  26. '../src/**/*.test.tsx': ['webpack', 'sourcemap'],
  27. '../src/**/*.test.ts': ['webpack', 'sourcemap'],
  28. },
  29. // test results reporter to use
  30. // possible values: 'dots', 'progress'
  31. // available reporters: https://npmjs.org/browse/keyword/karma-reporter
  32. reporters: ['progress', 'coverage-istanbul'],
  33. coverageIstanbulReporter: {
  34. reports: ['html', 'lcov', 'text-summary'],
  35. dir: path.join(__dirname, '..', 'coverage'),
  36. },
  37. // web server port
  38. port: 9876,
  39. // enable / disable colors in the output (reporters and logs)
  40. colors: true,
  41. // level of logging
  42. // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
  43. logLevel: config.LOG_INFO,
  44. // enable / disable watching file and executing tests whenever any file changes
  45. autoWatch: false,
  46. // start these browsers
  47. // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
  48. browsers: ['ChromeHeadless'],
  49. // Continuous Integration mode
  50. // if true, Karma captures browsers, runs the tests and exits
  51. singleRun: true,
  52. // Concurrency level
  53. // how many browser should be started simultaneous
  54. concurrency: Infinity,
  55. plugins: [
  56. 'karma-webpack',
  57. 'karma-jasmine',
  58. 'karma-sourcemap-loader',
  59. 'karma-coverage-istanbul-reporter',
  60. 'karma-chrome-launcher',
  61. ],
  62. mime: {
  63. 'text/x-typescript': ['ts', 'tsx']
  64. },
  65. webpack: webpackConfig,
  66. };
  67. config.set(configuration);
  68. };