test.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. var gulp = require('gulp');
  2. var path = require('path');
  3. var KarmaServer = require('karma').Server;
  4. var karmaConf = path.join(__dirname, '../karma.conf.js'); // was getting confused with relative URLs
  5. // runs a server, outputs a URL to visit
  6. gulp.task('test', [ 'modules', 'lang' ], function(done) {
  7. new KarmaServer({
  8. configFile: karmaConf,
  9. singleRun: false,
  10. autoWatch: true
  11. }, function(exitCode) { // plays best with developing from command line
  12. process.exit(exitCode);
  13. }).start();
  14. });
  15. // runs headlessly and continuously, watching files
  16. gulp.task('test:headless', [ 'modules', 'lang' ], function(done) {
  17. new KarmaServer({
  18. configFile: karmaConf,
  19. browsers: [ 'PhantomJS_custom' ],
  20. singleRun: false,
  21. autoWatch: true
  22. }, function(exitCode) { // plays best with developing from command line
  23. process.exit(exitCode);
  24. }).start();
  25. });
  26. // runs headlessly once, then exits
  27. gulp.task('test:single', [ 'modules', 'lang' ], function(done) {
  28. new KarmaServer({
  29. configFile: karmaConf,
  30. browsers: [ 'PhantomJS_custom' ],
  31. singleRun: true,
  32. autoWatch: false
  33. }).on('run_complete', function(browsers, results) { // plays best with CI and other tasks
  34. done(results.exitCode);
  35. }).start();
  36. });