karma.config.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. const fs = require('fs')
  2. const argv = require('yargs').argv
  3. writeConfig()
  4. module.exports = function(config) {
  5. config.set({
  6. // base path, that will be used to resolve files and exclude
  7. basePath: '',
  8. // frameworks to use
  9. frameworks: [ 'jasmine' ],
  10. // list of files / patterns to load in the browser
  11. files: [
  12. // dependencies for main lib
  13. 'node_modules/moment/moment.js',
  14. 'node_modules/jquery/dist/jquery.js',
  15. 'node_modules/components-jqueryui/jquery-ui.js',
  16. 'node_modules/components-jqueryui/themes/cupertino/jquery-ui.css',
  17. // main lib files
  18. 'dist/fullcalendar.js',
  19. 'dist/fullcalendar.css',
  20. 'dist/gcal.js',
  21. 'dist/locale-all.js',
  22. // a way to dump variables into the test environment
  23. 'tmp/automated-test-config.js',
  24. // so plugins can dump files into here and test side effects
  25. 'tmp/test-side-effects/*.js',
  26. // dependencies for tests
  27. 'node_modules/native-promise-only/lib/npo.src.js',
  28. 'node_modules/jquery-mockjax/dist/jquery.mockjax.js',
  29. 'node_modules/jasmine-jquery/lib/jasmine-jquery.js',
  30. 'node_modules/jasmine-fixture/dist/jasmine-fixture.js',
  31. 'node_modules/jquery-simulate/jquery.simulate.js',
  32. 'tests/automated/base.css',
  33. 'tmp/automated-tests.js',
  34. { // serve all other files
  35. pattern: '**/*',
  36. included: false, // don't immediately execute
  37. nocache: true, // don't let the webserver cache
  38. watched: false // don't let changes trigger tests to restart
  39. }
  40. ],
  41. preprocessors: {
  42. '**/*.js': [ 'sourcemap' ]
  43. },
  44. // test results reporter to use
  45. // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage', 'verbose'
  46. reporters: [ 'dots' ],
  47. // web server port
  48. port: 9876,
  49. // enable / disable colors in the output (reporters and logs)
  50. colors: true,
  51. // level of logging
  52. // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
  53. logLevel: config.LOG_INFO,
  54. // enable / disable watching file and executing tests whenever any file changes
  55. autoWatch: true,
  56. // If browser does not capture in given timeout [ms], kill it
  57. captureTimeout: 60000,
  58. // force a window size for PhantomJS, because it's usually unreasonably small, resulting in offset problems
  59. customLaunchers: {
  60. PhantomJS_custom: {
  61. base: 'PhantomJS',
  62. options: {
  63. viewportSize: {
  64. width: 1024,
  65. height: 768
  66. }
  67. }
  68. }
  69. }
  70. })
  71. }
  72. function writeConfig() {
  73. let config = {
  74. isTravis: ('travis' in argv)
  75. }
  76. if (!fs.existsSync('tmp')) {
  77. fs.mkdirSync('tmp')
  78. }
  79. fs.writeFileSync(
  80. 'tmp/automated-test-config.js',
  81. 'window.karmaConfig = ' + JSON.stringify(config),
  82. { encoding: 'utf8' }
  83. )
  84. }