test.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const path = require('path')
  2. const gulp = require('gulp')
  3. const KarmaServer = require('karma').Server
  4. const karmaConfigPath = path.join(__dirname, '../karma.config.js')
  5. // runs a server, outputs a URL to visit.
  6. // expects dist to be compiled or watcher to be running.
  7. gulp.task('test', function() {
  8. new KarmaServer({
  9. configFile: karmaConfigPath,
  10. singleRun: false,
  11. autoWatch: true
  12. }, function(exitCode) { // plays best with developing from command line
  13. process.exit(exitCode)
  14. }).start()
  15. })
  16. // runs headlessly and continuously, watching files.
  17. // expects dist to be compiled or watcher to be running.
  18. gulp.task('test:headless', function() {
  19. new KarmaServer({
  20. configFile: karmaConfigPath,
  21. browsers: [ 'PhantomJS_custom' ],
  22. singleRun: false,
  23. autoWatch: true
  24. }, function(exitCode) { // plays best with developing from command line
  25. process.exit(exitCode)
  26. }).start()
  27. })
  28. // runs headlessly once, then exits
  29. gulp.task('test:single', [ 'webpack' ], function(done) {
  30. new KarmaServer({
  31. configFile: karmaConfigPath,
  32. browsers: [ 'PhantomJS_custom' ],
  33. singleRun: true,
  34. autoWatch: false
  35. }).on('run_complete', function(browsers, results) { // plays best with CI and other tasks
  36. done(results.exitCode)
  37. }).start()
  38. })