Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Fixed duplicate reporting for HTML reporter. Closes #154

TJ Holowaychuk8ab0d5b81fdf
diff --git a/lib/reporters/html.js b/lib/reporters/html.js
index e118be7b..526baebe 100644
--- a/lib/reporters/html.js
+++ b/lib/reporters/html.js
@@ -67,7 +67,7 @@ function HTML(runner) {
});
runner.on('fail', function(test, err){
- runner.emit('test end', test);
+ if (err.uncaught) runner.emit('test end', test);
});
runner.on('test end', function(test){
diff --git a/lib/runner.js b/lib/runner.js
index fc44d1ea..17c176d2 100644
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -394,6 +394,7 @@ Runner.prototype.run = function(fn){
var runnable = self.currentRunnable;
debug('uncaught exception');
runnable.clearTimeout();
+ err.uncaught = true;
self.fail(runnable, err);
// recover from test
diff --git a/mocha.js b/mocha.js
index 629d6909..bc2df419 100644
--- a/mocha.js
+++ b/mocha.js
@@ -1141,7 +1141,7 @@ function HTML(runner) {
});
runner.on('fail', function(test, err){
- runner.emit('test end', test);
+ if (err.uncaught) runner.emit('test end', test);
});
runner.on('test end', function(test){
@@ -2383,6 +2383,7 @@ Runner.prototype.run = function(fn){
var runnable = self.currentRunnable;
debug('uncaught exception');
runnable.clearTimeout();
+ err.uncaught = true;
self.fail(runnable, err);
// recover from test
diff --git a/test/browser/index.html b/test/browser/index.html
index 69f525cd..fbc0c166 100644
--- a/test/browser/index.html
+++ b/test/browser/index.html
@@ -19,9 +19,9 @@
var runner = mocha.run();
runner.globals(['foo', 'bar', 'baz']);
- runner.on('test end', function(test){
- console.log(test.fullTitle());
- });
+ // runner.on('test end', function(test){
+ // console.log(test.fullTitle());
+ // });
};
</script>
</head>