From d45a38949c023b4148bcbf05450fb074729c37a5 Mon Sep 17 00:00:00 2001 From: juergba Date: Thu, 2 Jan 2020 18:47:06 +0100 Subject: [PATCH] additional test --- .../fixtures/uncaught/after-runner.fixture.js | 9 ++++++++ test/integration/uncaught.spec.js | 23 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 test/integration/fixtures/uncaught/after-runner.fixture.js diff --git a/test/integration/fixtures/uncaught/after-runner.fixture.js b/test/integration/fixtures/uncaught/after-runner.fixture.js new file mode 100644 index 0000000000..dbb6403b82 --- /dev/null +++ b/test/integration/fixtures/uncaught/after-runner.fixture.js @@ -0,0 +1,9 @@ +'use strict'; + +describe("Uncaught exception after runner's end", () => { + it('test', () => { + setTimeout(() => { + throw new Error('Unexpected crash'); + }, 100); + }); +}); diff --git a/test/integration/uncaught.spec.js b/test/integration/uncaught.spec.js index 8202ff3346..4c2fd94b43 100644 --- a/test/integration/uncaught.spec.js +++ b/test/integration/uncaught.spec.js @@ -3,6 +3,7 @@ var assert = require('assert'); var helpers = require('./helpers'); var run = helpers.runMochaJSON; +var runMocha = helpers.runMocha; var args = []; describe('uncaught exceptions', function() { @@ -88,6 +89,28 @@ describe('uncaught exceptions', function() { }); }); + it("handles uncaught exceptions after runner's end", function(done) { + runMocha( + 'uncaught/after-runner.fixture.js', + args, + function(err, res) { + if (err) { + return done(err); + } + + expect(res, 'to have failed').and('to satisfy', { + failing: 0, + passing: 1, + pending: 0, + output: expect.it('to contain', 'Error: Unexpected crash') + }); + + done(); + }, + 'pipe' + ); + }); + it('issue-1327: should run the first test and then bail', function(done) { run('uncaught/issue-1327.fixture.js', args, function(err, res) { if (err) {