karma.conf.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. 'use strict'
  2. const path = require('path')
  3. const merge = require('webpack-merge')
  4. const webpack = require('webpack')
  5. const baseConfig = require('../../.electron-vue/webpack.renderer.config')
  6. const projectRoot = path.resolve(__dirname, '../../src/renderer')
  7. // Set BABEL_ENV to use proper preset config
  8. process.env.BABEL_ENV = 'test'
  9. let webpackConfig = merge(baseConfig, {
  10. devtool: '#inline-source-map',
  11. plugins: [
  12. new webpack.DefinePlugin({
  13. 'process.env.NODE_ENV': '"testing"'
  14. })
  15. ]
  16. })
  17. // don't treat dependencies as externals
  18. delete webpackConfig.entry
  19. delete webpackConfig.externals
  20. delete webpackConfig.output.libraryTarget
  21. // apply vue option to apply isparta-loader on js
  22. webpackConfig.module.rules
  23. .find(rule => rule.use.loader === 'vue-loader').use.options.loaders.js = 'babel-loader'
  24. module.exports = config => {
  25. config.set({
  26. browsers: ['visibleElectron'],
  27. client: {
  28. useIframe: false
  29. },
  30. coverageReporter: {
  31. dir: './coverage',
  32. reporters: [
  33. { type: 'lcov', subdir: '.' },
  34. { type: 'text-summary' }
  35. ]
  36. },
  37. customLaunchers: {
  38. 'visibleElectron': {
  39. base: 'Electron',
  40. flags: ['--show']
  41. }
  42. },
  43. frameworks: ['mocha', 'chai'],
  44. files: ['./index.js'],
  45. preprocessors: {
  46. './index.js': ['webpack', 'sourcemap']
  47. },
  48. reporters: ['spec', 'coverage'],
  49. singleRun: true,
  50. webpack: webpackConfig,
  51. webpackMiddleware: {
  52. noInfo: true
  53. }
  54. })
  55. }