Collect unhandled exceptions and pass them to the current runnable

Fixes #529
Fixes #937
This commit is contained in:
Gregg Van Hove
2017-03-07 16:32:11 -08:00
parent 92e7436db2
commit 1042c9a2dd
8 changed files with 283 additions and 0 deletions

View File

@@ -1757,4 +1757,37 @@ describe("Env integration", function() {
env.execute();
});
it("should associate errors thrown from async code with the correct runnable", function(done) {
var env = new jasmineUnderTest.Env(),
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone','specDone']);
reporter.jasmineDone.and.callFake(function() {
expect(reporter.suiteDone).toHaveFailedExpecationsForRunnable('async suite', [
/^(((Uncaught )?Error: suite( thrown)?)|(suite thrown))$/
]);
expect(reporter.specDone).toHaveFailedExpecationsForRunnable('suite async spec', [
/^(((Uncaught )?Error: spec( thrown)?)|(spec thrown))$/
]);
done();
});
env.addReporter(reporter);
env.describe('async suite', function() {
env.afterAll(function(innerDone) {
setTimeout(function() { throw new Error('suite'); }, 1);
}, 10);
env.it('spec', function() {});
});
env.describe('suite', function() {
env.it('async spec', function(innerDone) {
setTimeout(function() { throw new Error('spec'); }, 1);
}, 10);
});
env.execute();
});
});