Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 6288d88

Browse files
fix(tests): CI error reporting improved
Running karma on ci was not exiting with non zero code, giving the impression the specs passed Closes #2535.
1 parent 3a256fb commit 6288d88

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

gulp/tasks/karma.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,27 @@ exports.task = function (done) {
66
configFile: root + '/config/karma.conf.js'
77
};
88

9+
var errorCount = 0;
10+
11+
function captureError(next) {
12+
return function(exitCode) {
13+
if (exitCode != 0) {
14+
gutil.log(gutil.colors.red("Karma exited with the following exit code: " + exitCode));
15+
errorCount++;
16+
}
17+
next();
18+
};
19+
}
20+
21+
922
gutil.log('Running unit tests on unminified source.');
1023
buildJs(true);
11-
karma.start(karmaConfig, testMinified);
24+
karma.start(karmaConfig, captureError(testMinified));
1225

1326
function testMinified() {
1427
gutil.log('Running unit tests on minified source.');
1528
process.env.KARMA_TEST_COMPRESSED = true;
16-
karma.start(karmaConfig, testMinifiedJquery);
29+
karma.start(karmaConfig, captureError(testMinifiedJquery));
1730
}
1831

1932
function testMinifiedJquery() {
@@ -26,6 +39,8 @@ exports.task = function (done) {
2639
function clearEnv() {
2740
process.env.KARMA_TEST_COMPRESSED = undefined;
2841
process.env.KARMA_TEST_JQUERY = undefined;
42+
43+
if (errorCount > 0) { process.exit(errorCount); }
2944
done();
3045
}
3146
};

0 commit comments

Comments
 (0)