-
-
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
Sets the allowUncaught parameter for hooks. #2303
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -315,6 +315,17 @@ describe('Runner', function(){ | |
}); | ||
|
||
describe('allowUncaught', function() { | ||
var immediately; | ||
|
||
before(function() { | ||
immediately = Runner.immediately; | ||
Runner.immediately = function(fn) { fn(); }; | ||
}); | ||
|
||
after(function() { | ||
Runner.immediately = immediately; | ||
}); | ||
|
||
it('should allow unhandled errors to propagate through', function(done) { | ||
var newRunner = new Runner(suite); | ||
newRunner.allowUncaught = true; | ||
|
@@ -327,6 +338,19 @@ describe('Runner', function(){ | |
fail.should.throw('allow unhandled errors'); | ||
done(); | ||
}); | ||
|
||
it('should allow unhandled errors in hooks to propagate through', function(done) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this doesn't appear to be async, so you don't need Ideally, I'd like to see both sync and async tests against this behavior. Can you please add an async version? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I will correct soon and I will add the asynchronous version There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @boneskull I'm sorry for delay. I can not think of a good way, how to check the exception handling asynchronously. Perhaps I not fully understand the problem. Please give me an advice on how to do it correctly. |
||
var runner = new Runner(suite); | ||
runner.allowUncaught = true; | ||
suite.beforeEach(function(){ | ||
throw new Error('allow unhandled errors in hooks'); | ||
}); | ||
function fail() { | ||
runner.hook('beforeEach', function() {}); | ||
} | ||
fail.should.throw('allow unhandled errors in hooks'); | ||
done(); | ||
}); | ||
}); | ||
|
||
describe('stackTrace', function() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we monkeypatching
Runner.immediately()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was done in order to run the hook synchronously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need it to catch the exception in the test method, instead of catching it on a global error handler.