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