karma.conf.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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: ['./index.js'],
  54. preprocessors: {
  55. './index.js': ['webpack', 'sourcemap']
  56. },
  57. webpack: webpackConfig,
  58. webpackMiddleware: {
  59. noInfo: true
  60. },
  61. mochaReporter: {
  62. showDiff: true
  63. },
  64. coverageReporter: {
  65. dir: './coverage',
  66. reporters: [
  67. { type: 'lcov', subdir: '.' },
  68. { type: 'text-summary' }
  69. ]
  70. }
  71. })
  72. }