gulp-jasmine icon indicating copy to clipboard operation
gulp-jasmine copied to clipboard

Crashing on uncaught asynchronous exception

Open jbblanchet opened this issue 9 years ago • 1 comments

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

jbblanchet avatar Jul 11 '15 20:07 jbblanchet

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.

adrianolek avatar Sep 12 '15 22:09 adrianolek