gulp-jasmine
gulp-jasmine copied to clipboard
Crashing on uncaught asynchronous exception
Given this gulp task:
gulp.task('test', function() {
return gulp.src("*.spec.js")
.pipe(jasmine());
});
and this spec:
describe("a test", function () {
it("should work", function (done) {
setTimeout(function () {
throw "Exception";
done();
}, 1);
});
});
the output will be:
[16:24:21] Starting 'test'...
Running 1 specs.
a test
C:\POC\test-gulp-jasmine\test.spec.js:4
throw "Exception";
^
Exception
It would be nice to be able to catch the exception and return gracefully, but I guess this must be managed by jasmine directly and might not be possible at all.
Things that could be related:
- a catchException option: https://github.com/jasmine/jasmine/blob/master/src/core/Env.js#L138
- an issue related to exceptions in asynchronous code: https://github.com/jasmine/jasmine/issues/529
I think it must be possible, as Mocha handles and reports these asynchronous exceptions (didn't have a time to look into how it's done there).
It's a jasmine issue though, not related to gulp-jasmine.