-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
browser - exceptions thrown in before/beforeEach are ignored #270
Comments
I get the same in node |
+1. It appears like uncaught exceptions have their "uncaught" property set only when thrown from the actual test cases, not the hooks. |
+1 Seeing this in Chrome 17 with mocha@0.14.0 |
This was equivalently fixed with commit 701c538, thus this is a duplicate of issue 361. |
hey sorry guys i didnt see this one, are you guys still finding this? |
hey, yeah we are still seeing this. var assert = require('assert');
}); |
I get the following as expected:
beforeEach(function(done){
throw new Error('boom')
}) |
Okay, are you seeing the teardown function called after that ? |
I have about 140 tests on a certain app. Whenever an error occurs within a before/after hook the entire suite stops running. I think this is related to the error not being handled, as the OP mentions. The output looks fine to me, I would just prefer to keep the rest of the tests running. I am running mocha 1.8.1 and node 0.8.18. |
Not sure when the issue was fixed, but it's no longer a problem in 2.2.0 :) // When thrown in beforeEach
$ cat beforeEachError.js
describe('issue-270', function() {
before(function() {
console.log('before hook');
});
beforeEach(function() {
console.log('beforeEach hook');
throw new Error('beforeEach hook error');
});
afterEach(function() {
console.log('afterEach hook');
});
after(function() {
console.log('after hook');
});
it('test', function() {});
});
// Output
$ mocha beforeEachError.js
before hook
beforeEach hook
․afterEach hook
after hook
0 passing (6ms)
1 failing
1) issue-270 "before each" hook:
Error: beforeEach hook error
at Context.<anonymous> (beforeEachError.js:8:11)
// An example when thrown in before hook
$ cat beforeError.js
describe('issue-270', function() {
before(function() {
console.log('before hook');
throw new Error('before hook error');
});
beforeEach(function() {
console.log('beforeEach hook');
});
afterEach(function() {
console.log('afterEach hook');
invoked++;
});
after(function() {
console.log('after hook');
});
it('test', function() {});
});
// Output
$ mocha beforeError.js
before hook
․after hook
0 passing (6ms)
1 failing
1) issue-270 "before all" hook:
Error: before hook error
at Context.<anonymous> (beforeError.js:4:11) |
Wonderful, thanks! I just didn't want it to slip under the radar.
|
No problem! Happy it all worked out. |
Fantastic. |
I'm finding that exceptions thrown in my before/beforeEach blocks aren't being handled, it's simple enough to reproduce:
This is on the most recent version, 0.12.1 on Chrome 17 and FireFox 10
The text was updated successfully, but these errors were encountered: