karma.conf.js 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. const webpackConfig = require('./webpack.config.js');
  2. process.env.CHROME_BIN = '/snap/bin/chromium';
  3. module.exports = function(config) {
  4. config.set({
  5. //root path location to resolve paths defined in files and exclude
  6. basePath: '',
  7. //files/patterns to exclude from loaded files
  8. exclude: [],
  9. //files/patterns to load in the browser
  10. files: [
  11. {pattern: 'tests/*.spec.js',watched:true,served:true,included:true}
  12. /*parameters*/
  13. //watched: if autoWatch is true all files that have set watched to true will be watched for changes
  14. //served: should the files be served by Karma's webserver?
  15. //included: should the files be included in the browser using <script> tag?
  16. //nocache: should the files be served from disk on each request by Karma's webserver?
  17. /*assets*/
  18. //{pattern: '*.html', watched:true, served:true, included:false}
  19. //{pattern: 'images/*', watched:false, served:true, included:false}
  20. ],
  21. //executes the tests whenever one of watched files changes
  22. autoWatch: true,
  23. //if true, Karma will run tests and then exit browser
  24. singleRun:false,
  25. //if true, Karma fails on running empty test-suites
  26. failOnEmptyTestSuite:false,
  27. //reduce the kind of information passed to the bash
  28. logLevel: config.LOG_WARN, //config.LOG_DISABLE, config.LOG_ERROR, config.LOG_INFO, config.LOG_DEBUG
  29. //list of frameworks you want to use, only jasmine is installed automatically
  30. frameworks: ['jasmine'],
  31. //list of browsers to launch and capture
  32. browsers: ['ChromeHeadless'/*,'PhantomJS','Firefox','Edge','ChromeCanary','Opera','IE','Safari'*/],
  33. //list of reporters to use
  34. reporters: ['mocha','kjhtml'/*,'dots','progress','spec'*/],
  35. //address that the server will listen on, '0.0.0.0' is default
  36. listenAddress: '0.0.0.0',
  37. //hostname to be used when capturing browsers, 'localhost' is default
  38. hostname: 'localhost',
  39. //the port where the web server will be listening, 9876 is default
  40. port: 9876,
  41. //when a browser crashes, karma will try to relaunch, 2 is default
  42. retryLimit:0,
  43. //how long does Karma wait for a browser to reconnect, 2000 is default
  44. browserDisconnectTimeout: 5000,
  45. //how long will Karma wait for a message from a browser before disconnecting from it, 10000 is default
  46. browserNoActivityTimeout: 10000,
  47. //timeout for capturing a browser, 60000 is default
  48. captureTimeout: 60000,
  49. client: {
  50. //capture all console output and pipe it to the terminal, true is default
  51. captureConsole:false,
  52. //if true, Karma clears the context window upon the completion of running the tests, true is default
  53. clearContext:false,
  54. //run the tests on the same window as the client, without using iframe or a new window, false is default
  55. runInParent: false,
  56. //true: runs the tests inside an iFrame; false: runs the tests in a new window, true is default
  57. useIframe:true,
  58. jasmine:{
  59. //tells jasmine to run specs in semi random order, false is default
  60. random: false
  61. }
  62. },
  63. /*karma-webpack config*/
  64. //pass your webpack configuration for karma
  65. webpack: webpackConfig,
  66. preprocessors: {
  67. //use webpack to support require() in test-suits .js files
  68. //use babel-loader from webpack to compile es2015 features in .js files
  69. //add webpack as preprocessor
  70. './tests/*.js': ['webpack']
  71. },
  72. webpackMiddleware: {
  73. //turn off webpack bash output when run the tests
  74. noInfo: true,
  75. stats: 'errors-only'
  76. },
  77. /*karma-mocha-reporter config*/
  78. mochaReporter: {
  79. output: 'noFailures' //full, autowatch, minimal
  80. }
  81. });
  82. };