karma.config.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. const { writeFileSync } = require('./scripts/lib/util')
  2. let cmdArgs = process.argv.slice(2)
  3. let isRealCiEnv = Boolean(process.env.CI)
  4. let isCi = isRealCiEnv || cmdArgs.indexOf('ci') !== -1
  5. writeFileSync(
  6. 'tmp/tests-compiled/config.js',
  7. 'window.karmaConfig = ' + JSON.stringify({
  8. isCi: isRealCiEnv
  9. })
  10. )
  11. module.exports = function(config) {
  12. config.set({
  13. singleRun: isCi,
  14. autoWatch: !isCi,
  15. browsers: isCi ? [ 'ChromeHeadless_custom' ] : [],
  16. // base path, that will be used to resolve files and exclude
  17. basePath: '',
  18. // frameworks to use
  19. frameworks: [ 'jasmine' ],
  20. // list of files / patterns to load in the browser
  21. files: [
  22. // jquery-related deps should attach globally first
  23. 'node_modules/jquery/dist/jquery.js', // because of jquery-simulate and needing-to-be-first
  24. 'node_modules/jquery-simulate/jquery.simulate.js', // operates on global jQuery
  25. 'node_modules/jasmine-jquery/lib/jasmine-jquery.js', // weird this/root reference confuses rollup
  26. 'tmp/tests-compiled/config.js', // a way to dump variables into the test environment
  27. 'tmp/tests-compiled/main.js',
  28. { pattern: 'tmp/tests-compiled/main.css', watched: false }, // let the JS cause the refresh
  29. { pattern: 'tmp/tests-compiled/*.map', included: false, nocache: true, watched: false }
  30. ],
  31. // make console errors aware of source files
  32. preprocessors: {
  33. 'tmp/tests-compiled/*.+(js|css)': [ 'sourcemap' ]
  34. },
  35. // test results reporter to use
  36. // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage', 'verbose'
  37. reporters: [ 'dots' ],
  38. // web server port
  39. port: 9876,
  40. // enable / disable colors in the output (reporters and logs)
  41. colors: true,
  42. // level of logging
  43. // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
  44. logLevel: config.LOG_INFO,
  45. // If browser does not capture in given timeout [ms], kill it
  46. captureTimeout: 60000,
  47. customLaunchers: {
  48. ChromeHeadless_custom: {
  49. base: 'ChromeHeadless',
  50. flags: [
  51. '--no-sandbox', // needed for TravisCI: https://docs.travis-ci.com/user/chrome#Sandboxing
  52. '--window-size=1280,1696' // some tests only work with larger window (w?, h?)
  53. ]
  54. }
  55. }
  56. })
  57. }