karma.conf.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* eslint camelcase: 0 */
  2. module.exports = function(karma) {
  3. var args = karma.args || {};
  4. var config = {
  5. browsers: ['Firefox'],
  6. frameworks: ['browserify', 'jasmine'],
  7. reporters: ['progress', 'kjhtml'],
  8. preprocessors: {
  9. './test/jasmine.index.js': ['browserify'],
  10. './src/**/*.js': ['browserify']
  11. },
  12. browserify: {
  13. debug: true
  14. },
  15. // These settings deal with browser disconnects. We had seen test flakiness from Firefox
  16. // [Firefox 56.0.0 (Linux 0.0.0)]: Disconnected (1 times), because no message in 10000 ms.
  17. // https://github.com/jasmine/jasmine/issues/1327#issuecomment-332939551
  18. browserNoActivityTimeout: 60000,
  19. browserDisconnectTolerance: 3
  20. };
  21. // https://swizec.com/blog/how-to-run-javascript-tests-in-chrome-on-travis/swizec/6647
  22. if (process.env.TRAVIS) {
  23. config.browsers.push('chrome_travis_ci');
  24. config.customLaunchers = {
  25. chrome_travis_ci: {
  26. base: 'Chrome',
  27. flags: ['--no-sandbox']
  28. }
  29. };
  30. } else {
  31. config.browsers.push('Chrome');
  32. }
  33. if (args.coverage) {
  34. config.reporters.push('coverage');
  35. config.browserify.transform = ['browserify-istanbul'];
  36. // https://github.com/karma-runner/karma-coverage/blob/master/docs/configuration.md
  37. config.coverageReporter = {
  38. dir: 'coverage/',
  39. reporters: [
  40. {type: 'html', subdir: 'report-html'},
  41. {type: 'lcovonly', subdir: '.', file: 'lcov.info'}
  42. ]
  43. };
  44. }
  45. karma.set(config);
  46. };