karma.conf.js 2.4 KB

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