karma.conf.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const DEBUG = !!process.env.DEBUG
  2. if (!DEBUG) process.env.CHROME_BIN = require('puppeteer').executablePath()
  3. module.exports = function (config) {
  4. config.set({
  5. basePath: '',
  6. frameworks: ['mocha', 'chai'],
  7. plugins: [
  8. require('karma-mocha'),
  9. require('karma-chai'),
  10. require('karma-chrome-launcher'),
  11. require('karma-rollup-preprocessor')
  12. // require('karma-coverage')
  13. ],
  14. files: [
  15. { pattern: 'test/*-spec.js', watched: false }
  16. ],
  17. exclude: [],
  18. preprocessors: {
  19. 'test/*-spec.js': ['rollup']
  20. },
  21. // coverageReporter: {
  22. // type: 'html',
  23. // dir: 'coverage/'
  24. // },
  25. rollupPreprocessor: {
  26. plugins: [
  27. require('rollup-plugin-node-resolve')({
  28. jsnext: true,
  29. browser: true
  30. }),
  31. require('rollup-plugin-commonjs')(),
  32. require('rollup-plugin-babel')(),
  33. require('rollup-plugin-replace')({
  34. 'process.env.NODE_ENV': JSON.stringify('production')
  35. })
  36. ],
  37. format: 'iife', // Helps prevent naming collisions.
  38. name: 'lib', // Required for 'iife' format.
  39. sourcemap: 'inline' // Sensible for testing.
  40. },
  41. reporters: ['progress'],
  42. port: 9876,
  43. colors: true,
  44. logLevel: config.LOG_INFO,
  45. autoWatch: true,
  46. browsers: DEBUG ? ['Chrome'] : ['ChromeHeadless'],
  47. singleRun: !DEBUG,
  48. concurrency: Infinity
  49. })
  50. }