karma.config.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. const { writeFileSync } = require('./scripts/lib/util')
  2. writeConfig()
  3. module.exports = function(config) {
  4. config.set({
  5. // base path, that will be used to resolve files and exclude
  6. basePath: '',
  7. // frameworks to use
  8. frameworks: [ 'jasmine' ],
  9. // list of files / patterns to load in the browser
  10. // TODO: to test IE11, must comment-out luxon test
  11. files: [
  12. 'packages/__tests__/src/base.css',
  13. // fullcalendar CSS must be manually included :(
  14. 'packages/core/dist/main.css', // always needs to be first
  15. 'packages/daygrid/dist/main.css', // because timegrid depends on it
  16. 'packages-premium/timeline/dist/main.css', // because resource-timeline depends on it
  17. 'packages?(-premium)/*/dist/main.css',
  18. { pattern: 'packages?(-premium)/*/dist/main.css.map', included: false, nocache: true, watched: false },
  19. // tests dependencies that are old or depend on order, so put them first
  20. 'node_modules/jquery/dist/jquery.js', // because of jquery-simulate and needing-to-be-first
  21. 'node_modules/jquery-simulate/jquery.simulate.js', // operates on global jQuery
  22. 'node_modules/jasmine-jquery/lib/jasmine-jquery.js', // weird this/root reference confuses rollup
  23. 'node_modules/native-promise-only/lib/npo.src.js', // needed by xhr-mock for IE11
  24. 'node_modules/xhr-mock/dist/xhr-mock.js', // esm requires node libs
  25. // hack for hoisting workaround. see rollup.config.js
  26. // TODO: afterwards, remove as many of these entries as possible from the root package.json
  27. 'node_modules/luxon/build/global/luxon.js',
  28. 'node_modules/rrule/dist/es5/rrule.js',
  29. 'node_modules/moment/moment.js',
  30. 'node_modules/moment/locale/es.js',
  31. 'node_modules/moment-timezone/builds/moment-timezone-with-data.js',
  32. 'tmp/test-config.js', // a way to dump variables into the test environment
  33. 'tmp/tests.js',
  34. { pattern: 'tmp/tests.js.map', included: false, nocache: true, watched: false }
  35. ],
  36. // make console errors aware of source files
  37. preprocessors: {
  38. '**/*.js': ['sourcemap']
  39. },
  40. // test results reporter to use
  41. // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage', 'verbose'
  42. reporters: [ 'dots' ],
  43. // web server port
  44. port: 9876,
  45. // enable / disable colors in the output (reporters and logs)
  46. colors: true,
  47. // level of logging
  48. // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
  49. logLevel: config.LOG_INFO,
  50. // enable / disable watching file and executing tests whenever any file changes
  51. autoWatch: true,
  52. autoWatchBatchDelay: 1000, // try to fix karma crashing on imcomplete syntax
  53. // If browser does not capture in given timeout [ms], kill it
  54. captureTimeout: 60000,
  55. customLaunchers: {
  56. ChromeHeadless_custom: {
  57. base: 'ChromeHeadless',
  58. flags: [
  59. '--no-sandbox', // needed for TravisCI: https://docs.travis-ci.com/user/chrome#Sandboxing
  60. '--window-size=1280,1696' // some tests only work with larger window (w?, h?)
  61. ]
  62. }
  63. }
  64. })
  65. }
  66. function writeConfig() {
  67. let config = {
  68. isCi: Boolean(process.env.CI)
  69. }
  70. writeFileSync(
  71. 'tmp/test-config.js',
  72. 'window.karmaConfig = ' + JSON.stringify(config)
  73. )
  74. }