Skip to content
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

Fix HTML reporting display to show errors if done is called multiple times, or if an exception is thrown after done is called. #1981

Merged
merged 1 commit into from
Dec 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/reporters/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ function HTML(runner) {
});

runner.on('fail', function(test) {
if (test.type === 'hook') {
// For type = 'test' its possible that the test failed due to multiple
// done() calls. So report the issue here.
if (test.type === 'hook'
|| test.type === 'test') {
runner.emit('test end', test);
}
});
Expand Down
1 change: 1 addition & 0 deletions test/browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<script src="array.js"></script>
<script src="../acceptance/duration.js"></script>
<script src="../acceptance/timeout.js"></script>
<script src="multiple-done.js"></script>
<script>
onload = function(){
mocha.checkLeaks();
Expand Down
16 changes: 16 additions & 0 deletions test/browser/multiple-done.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
describe('Multiple Done calls', function(){
it('should report an error if done was called more than once', function(done){
done();
done();
})

it('should report an error if an exception happened async after done was called', function (done) {
done();
setTimeout(done, 50);
})

it('should report an error if an exception happened after done was called', function(done){
done();
throw new Error("thrown error");
})
})