blob: 5b905727e244c710b8133501f9426f21981faa82 [file] [log] [blame]
Matteo Scandolod819c922016-12-02 14:06:14 -08001const path = require('path');
2
3const gulp = require('gulp');
4const karma = require('karma');
5
6gulp.task('karma:single-run', karmaSingleRun);
7gulp.task('karma:auto-run', karmaAutoRun);
8
9function karmaFinishHandler(done) {
10 return failCount => {
11 done(failCount ? new Error(`Failed ${failCount} tests.`) : null);
12 };
13}
14
15function karmaSingleRun(done) {
Matteo Scandolo43ffb672016-12-02 14:49:58 -080016 process.env.NODE_ENV = 'test';
Matteo Scandolod819c922016-12-02 14:06:14 -080017 const configFile = path.join(process.cwd(), 'conf', 'karma.conf.js');
18 const karmaServer = new karma.Server({configFile}, karmaFinishHandler(done));
19 karmaServer.start();
20}
21
22function karmaAutoRun(done) {
Matteo Scandolo43ffb672016-12-02 14:49:58 -080023 process.env.NODE_ENV = 'test';
Matteo Scandolod819c922016-12-02 14:06:14 -080024 const configFile = path.join(process.cwd(), 'conf', 'karma-auto.conf.js');
25 const karmaServer = new karma.Server({configFile}, karmaFinishHandler(done));
26 karmaServer.start();
27}