karma.conf.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // This is a karma config file. For more details see
  2. // http://karma-runner.github.io/0.13/config/configuration-file.html
  3. // we are also using it with karma-webpack
  4. // https://github.com/webpack/karma-webpack
  5. // var path = require('path')
  6. var merge = require('webpack-merge')
  7. var baseConfig = require('../../build/webpack.base.conf')
  8. var utils = require('../../build/utils')
  9. var webpack = require('webpack')
  10. // var projectRoot = path.resolve(__dirname, '../../')
  11. var webpackConfig = merge(baseConfig, {
  12. // use inline sourcemap for karma-sourcemap-loader
  13. module: {
  14. rules: utils.styleLoaders()
  15. },
  16. devtool: '#inline-source-map',
  17. // vue: {
  18. // loaders: {
  19. // js: 'isparta'
  20. // }
  21. // },
  22. plugins: [
  23. new webpack.DefinePlugin({
  24. 'process.env': require('../../config/test.env')
  25. })
  26. ]
  27. })
  28. // no need for app entry during tests
  29. delete webpackConfig.entry
  30. // make sure isparta loader is applied before eslint
  31. // webpackConfig.module.preLoaders = webpackConfig.module.preLoaders || []
  32. // webpackConfig.module.preLoaders.unshift({
  33. // test: /\.js$/,
  34. // loader: 'isparta',
  35. // include: path.resolve(projectRoot, 'src')
  36. // })
  37. // // only apply babel for test files when using isparta
  38. // webpackConfig.module.loaders.some(function (loader, i) {
  39. // if (loader.loader === 'babel') {
  40. // loader.include = path.resolve(projectRoot, 'test/unit')
  41. // return true
  42. // }
  43. // })
  44. module.exports = function (config) {
  45. config.set({
  46. // to run in additional browsers:
  47. // 1. install corresponding karma launcher
  48. // http://karma-runner.github.io/0.13/config/browsers.html
  49. // 2. add it to the `browsers` array below.
  50. browsers: ['FirefoxHeadless'],
  51. frameworks: ['mocha', 'sinon-chai'],
  52. reporters: ['mocha'],
  53. customLaunchers: {
  54. 'FirefoxHeadless': {
  55. base: 'Firefox',
  56. flags: [
  57. '-headless'
  58. ]
  59. }
  60. },
  61. files: [
  62. './index.js'
  63. ],
  64. preprocessors: {
  65. './index.js': ['webpack', 'sourcemap']
  66. },
  67. webpack: webpackConfig,
  68. webpackMiddleware: {
  69. noInfo: true
  70. },
  71. mochaReporter: {
  72. showDiff: true
  73. },
  74. coverageReporter: {
  75. dir: './coverage',
  76. reporters: [
  77. { type: 'lcov', subdir: '.' },
  78. { type: 'text-summary' }
  79. ]
  80. }
  81. })
  82. }