From 5c3a8cf87182b6a029e65c50346f4cb58a8ceae0 Mon Sep 17 00:00:00 2001 From: juergba Date: Wed, 15 Jan 2020 10:00:10 +0100 Subject: [PATCH] additional test --- .../fixtures/uncaught/recover.fixture.js | 28 +++++++++++++++++++ test/integration/uncaught.spec.js | 27 ++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 test/integration/fixtures/uncaught/recover.fixture.js diff --git a/test/integration/fixtures/uncaught/recover.fixture.js b/test/integration/fixtures/uncaught/recover.fixture.js new file mode 100644 index 0000000000..945decb045 --- /dev/null +++ b/test/integration/fixtures/uncaught/recover.fixture.js @@ -0,0 +1,28 @@ +'use strict'; +const assert = require('assert'); + +describe('uncaught', function() { + var hookOrder = []; + it('throw delayed error', (done) => { + setTimeout(() => { + throw new Error('Whoops!'); + }, 10) + setTimeout(done, 10); + }); + it('should wait 15ms', (done) => { + setTimeout(done, 15); + }); + it('test 3', () => { }); + + afterEach(function() { + hookOrder.push(this.currentTest.title); + }); + after(function() { + hookOrder.push('after'); + assert.deepEqual( + hookOrder, + ['throw delayed error', 'should wait 15ms', 'test 3', 'after'] + ); + throw new Error('should get upto here and throw'); + }); +}); diff --git a/test/integration/uncaught.spec.js b/test/integration/uncaught.spec.js index 001c89429a..5b193280bc 100644 --- a/test/integration/uncaught.spec.js +++ b/test/integration/uncaught.spec.js @@ -87,6 +87,33 @@ describe('uncaught exceptions', function() { }); }); + it('handles uncaught exceptions within open tests', function(done) { + run('uncaught/recover.fixture.js', args, function(err, res) { + if (err) { + return done(err); + } + + expect( + res, + 'to have failed with error', + 'Whoops!', + 'Whoops!', // JSON reporter does not show the second error message + 'should get upto here and throw' + ) + .and('to have passed test count', 2) + .and('to have failed test count', 3) + .and('to have passed test', 'should wait 15ms', 'test 3') + .and( + 'to have failed test', + 'throw delayed error', + 'throw delayed error', + '"after all" hook for "test 3"' + ); + + done(); + }); + }); + it('removes uncaught exceptions handlers correctly', function(done) { run('uncaught/listeners.fixture.js', args, function(err, res) { if (err) {