karma.conf.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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: 'babel-loader'
  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. // Use babel for test files too
  31. webpackConfig.module.loaders.some(function (loader, i) {
  32. if (/^babel(-loader)?$/.test(loader.loader)) {
  33. loader.include.push(path.resolve(projectRoot, 'test/unit'))
  34. return true
  35. }
  36. })
  37. module.exports = function (config) {
  38. config.set({
  39. // to run in additional browsers:
  40. // 1. install corresponding karma launcher
  41. // http://karma-runner.github.io/0.13/config/browsers.html
  42. // 2. add it to the `browsers` array below.
  43. browsers: ['PhantomJS'],
  44. frameworks: ['mocha', 'sinon-chai'],
  45. reporters: ['spec', 'coverage'],
  46. files: ['./index.js'],
  47. preprocessors: {
  48. './index.js': ['webpack', 'sourcemap']
  49. },
  50. webpack: webpackConfig,
  51. webpackMiddleware: {
  52. noInfo: true
  53. },
  54. coverageReporter: {
  55. dir: './coverage',
  56. reporters: [
  57. { type: 'lcov', subdir: '.' },
  58. { type: 'text-summary' }
  59. ]
  60. }
  61. })
  62. }