☕️ Classic, reliable, trusted test framework for Node.js and the browser
Adds support for loading reporter from an absolute or relative path.
Sulabh Bista265299d47edb
diff --git a/lib/mocha.js b/lib/mocha.jsindex dcc1492f..8bacf27b 100644--- a/lib/mocha.js+++ b/lib/mocha.js@@ -152,9 +152,17 @@ Mocha.prototype.reporter = function (reporter, reporterOptions) {try {_reporter = require(reporter);} catch (err) {- err.message.indexOf('Cannot find module') !== -1- ? console.warn('"' + reporter + '" reporter not found')- : console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack);+ if (err.message.indexOf('Cannot find module') !== -1) {+ // Try to load reporters from a path (absolute or relative)+ try {+ _reporter = require(path.resolve(process.cwd(), reporter));+ } catch (_err) {+ err.message.indexOf('Cannot find module') !== -1 ? console.warn('"' + reporter + '" reporter not found')+ : console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack);+ }+ } else {+ console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack);+ }}}if (!_reporter && reporter === 'teamcity') {