Skip to content

Commit

Permalink
temporarily disable uncaughtException handler
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Hiller <[email protected]>
  • Loading branch information
boneskull committed Dec 9, 2017
1 parent 42280e8 commit 86bc9c8
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions test/unit/throw.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,23 @@ var Test = require('../../lib/test');
var Runner = require('../../lib/runner');

describe('a test that throws', function () {
var suite, runner;
var suite;
var runner;
var uncaughtHandlers;

beforeEach(function () {
suite = new Suite('Suite', 'root');
runner = new Runner(suite);

// see https://github.com/mochajs/mocha/pull/2983#issuecomment-350428522
uncaughtHandlers = process.listeners('uncaughtException') || [];
process.removeAllListeners('uncaughtException');
});

afterEach(function () {
uncaughtHandlers.forEach(function (listener) {
process.on('uncaughtException', listener);
});
});

describe('undefined', function () {
Expand Down Expand Up @@ -51,15 +63,10 @@ describe('a test that throws', function () {
});
suite.addTest(test);
runner = new Runner(suite);
var uncaught = Runner.prototype.uncaught;
Runner.prototype.uncaught = function () {
Runner.prototype.uncaught = uncaught;
done();
};
runner.on('end', function () {
expect(runner.failures).to.equal(1);
expect(test.state).to.equal('failed');
expect(runner.uncaught).toBeCalled();
done();
});
runner.run();
});
Expand Down Expand Up @@ -102,15 +109,10 @@ describe('a test that throws', function () {
});
suite.addTest(test);
runner = new Runner(suite);
var uncaught = Runner.prototype.uncaught;
Runner.prototype.uncaught = function () {
Runner.prototype.uncaught = uncaught;
done();
};
runner.on('end', function () {
expect(runner.failures).to.equal(1);
expect(test.state).to.equal('failed');
expect(runner.uncaught).toBeCalled();
done();
});
runner.run();
});
Expand Down

0 comments on commit 86bc9c8

Please sign in to comment.