Skip to content

Commit

Permalink
additional test
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Jan 16, 2020
1 parent e334a72 commit 085de5c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/integration/fixtures/uncaught/recover.fixture.js
Original file line number Diff line number Diff line change
@@ -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');
});
});
27 changes: 27 additions & 0 deletions test/integration/uncaught.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 085de5c

Please sign in to comment.