karma.conf.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. logLevel: 'debug',
  54. browserConsoleLogOptions: {
  55. level: "debug",
  56. format: "%b %T: %m",
  57. terminal: true
  58. },
  59. customLaunchers: {
  60. 'FirefoxHeadless': {
  61. base: 'Firefox',
  62. flags: [
  63. '--headless',
  64. '--no-remote'
  65. ]
  66. }
  67. },
  68. files: [
  69. './index.js'
  70. ],
  71. preprocessors: {
  72. './index.js': ['webpack', 'sourcemap']
  73. },
  74. webpack: webpackConfig,
  75. webpackMiddleware: {
  76. noInfo: true
  77. },
  78. mochaReporter: {
  79. showDiff: true
  80. },
  81. coverageReporter: {
  82. dir: './coverage',
  83. reporters: [
  84. { type: 'lcov', subdir: '.' },
  85. { type: 'text-summary' }
  86. ]
  87. }
  88. })
  89. }