Skip to content

Commit

Permalink
additional test
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Jan 15, 2020
1 parent 36c5caa commit 3bdf7f1
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/integration/fixtures/uncaught/recover.fixture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'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 15 ms', (done) => {
setTimeout(done, 15);
});
it('test 3', () => { });

afterEach(function() {
hookOrder.push('afterEach');
});
after(function() {
hookOrder.push('after');
assert.deepEqual(hookOrder, ['afterEach', 'afterEach', 'afterEach', '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 15 ms', '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 3bdf7f1

Please sign in to comment.