karma.conf.js 3.6 KB

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