karma.conf.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. 'use strict';
  2. var webpack = require('webpack');
  3. var WATCH = process.argv.indexOf('--watch') > -1;
  4. var webpackConfig = {
  5. cache: true,
  6. devtool: 'inline-source-map',
  7. module: {
  8. preLoaders: [{
  9. test: /\.js$/,
  10. loaders: ['eslint'],
  11. exclude: /node_modules/
  12. }, {
  13. test: /\.html$/,
  14. loader: 'htmlhint',
  15. exclude: /node_modules/
  16. }],
  17. loaders: [{
  18. test: /\.html$/,
  19. loader: 'html',
  20. exclude: /node_modules/
  21. }, {
  22. test: /\.less/,
  23. loader: 'null',
  24. exclude: /node_modules/
  25. }],
  26. postLoaders: [{
  27. test: /\.js$/,
  28. exclude: /(test|node_modules)/,
  29. loader: 'istanbul-instrumenter'
  30. }]
  31. },
  32. plugins: [
  33. new webpack.optimize.DedupePlugin(),
  34. new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
  35. new webpack.DefinePlugin({
  36. EXCLUDE_TEMPLATES: false
  37. })
  38. ]
  39. };
  40. if (!WATCH) {
  41. webpackConfig.plugins.push(new webpack.NoErrorsPlugin());
  42. }
  43. module.exports = function(config) {
  44. config.set({
  45. // base path that will be used to resolve all patterns (eg. files, exclude)
  46. basePath: './',
  47. // frameworks to use
  48. // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
  49. frameworks: ['mocha', 'chai', 'chai-as-promised', 'sinon-chai', 'chai-things'],
  50. // list of files / patterns to load in the browser
  51. files: [
  52. 'test/unit/entry.js'
  53. ],
  54. // list of files to exclude
  55. exclude: [
  56. ],
  57. // preprocess matching files before serving them to the browser
  58. // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
  59. preprocessors: {
  60. 'test/unit/entry.js': ['webpack', 'sourcemap']
  61. },
  62. coverageReporter: {
  63. reporters: [{
  64. type: 'text-summary'
  65. }, {
  66. type: 'html'
  67. }]
  68. },
  69. webpack: webpackConfig,
  70. // test results reporter to use
  71. // possible values: 'dots', 'progress'
  72. // available reporters: https://npmjs.org/browse/keyword/karma-reporter
  73. reporters: ['progress', 'coverage'],
  74. // web server port
  75. port: 9876,
  76. // enable / disable colors in the output (reporters and logs)
  77. colors: true,
  78. // level of logging
  79. // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
  80. logLevel: config.LOG_INFO,
  81. // enable / disable watching file and executing tests whenever any file changes
  82. autoWatch: WATCH,
  83. // start these browsers
  84. // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
  85. browsers: ['PhantomJS'],
  86. // Continuous Integration mode
  87. // if true, Karma captures browsers, runs the tests and exits
  88. singleRun: !WATCH
  89. });
  90. };