karma.conf.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. loaders: 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: ['PhantomJS'],
  51. frameworks: ['mocha', 'sinon-chai'],
  52. reporters: ['mocha'],
  53. files: [
  54. '../../node_modules/@babel/polyfill/dist/polyfill.js',
  55. './index.js'
  56. ],
  57. preprocessors: {
  58. './index.js': ['webpack', 'sourcemap']
  59. },
  60. webpack: webpackConfig,
  61. webpackMiddleware: {
  62. noInfo: true
  63. },
  64. mochaReporter: {
  65. showDiff: true
  66. },
  67. coverageReporter: {
  68. dir: './coverage',
  69. reporters: [
  70. { type: 'lcov', subdir: '.' },
  71. { type: 'text-summary' }
  72. ]
  73. }
  74. })
  75. }