Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Added warning when strings are thrown as errors

TJ Holowaychukb37afeff7c21
diff --git a/lib/runner.js b/lib/runner.js
index 2599d55f..1e7148a2 100644
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -138,6 +138,9 @@ Runner.prototype.checkGlobals = function(test){
Runner.prototype.fail = function(test, err){
++this.failures;
test.state = 'failed';
+ if ('string' == typeof err) {
+ err = new Error('the string "' + err + '" was thrown, throw an Error :)');
+ }
this.emit('fail', test, err);
};