karma.conf.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. const merge = require('webpack-merge')
  7. const HtmlWebpackPlugin = require('html-webpack-plugin')
  8. const baseConfig = require('../../build/webpack.base.conf')
  9. const utils = require('../../build/utils')
  10. const webpack = require('webpack')
  11. // var projectRoot = path.resolve(__dirname, '../../')
  12. const webpackConfig = merge(baseConfig, {
  13. // use inline sourcemap for karma-sourcemap-loader
  14. module: {
  15. rules: utils.styleLoaders()
  16. },
  17. devtool: 'inline-source-map',
  18. plugins: [
  19. new webpack.DefinePlugin({
  20. 'process.env': require('../../config/test.env')
  21. }),
  22. new HtmlWebpackPlugin({
  23. filename: 'index.html',
  24. template: 'index.html',
  25. inject: true
  26. })
  27. ]
  28. })
  29. // no need for app entry during tests
  30. delete webpackConfig.entry
  31. module.exports = function (config) {
  32. config.set({
  33. // to run in additional browsers:
  34. // 1. install corresponding karma launcher
  35. // http://karma-runner.github.io/0.13/config/browsers.html
  36. // 2. add it to the `browsers` array below.
  37. browsers: ['FirefoxHeadless'],
  38. frameworks: ['mocha', 'sinon-chai'],
  39. reporters: ['mocha'],
  40. customLaunchers: {
  41. FirefoxHeadless: {
  42. base: 'Firefox',
  43. flags: [
  44. '-headless'
  45. ]
  46. }
  47. },
  48. files: [
  49. './index.js'
  50. ],
  51. preprocessors: {
  52. './index.js': ['webpack', 'sourcemap']
  53. },
  54. webpack: webpackConfig,
  55. webpackMiddleware: {
  56. noInfo: true
  57. },
  58. mochaReporter: {
  59. showDiff: true
  60. },
  61. coverageReporter: {
  62. dir: './coverage',
  63. reporters: [
  64. { type: 'lcov', subdir: '.' },
  65. { type: 'text-summary' }
  66. ]
  67. }
  68. })
  69. }