Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Add local uis and reporters (close #1288)

Travis Jeffery5bfab5995995
diff --git a/lib/mocha.js b/lib/mocha.js
index 4956684a..8e57487d 100644
--- a/lib/mocha.js
+++ b/lib/mocha.js
@@ -17,6 +17,16 @@ var path = require('path')
exports = module.exports = Mocha;
+/**
+ * To require local UIs and reporters when running in node.
+ */
+
+if (typeof process !== 'undefined' && typeof process.cwd === 'function') {
+ var join = path.join
+ , cwd = process.cwd();
+ module.paths.push(cwd, join(cwd, 'node_modules'));
+}
+
/**
* Expose internals.
*/
diff --git a/mocha.js b/mocha.js
index 71fb15fd..972f7cd2 100644
--- a/mocha.js
+++ b/mocha.js
@@ -1404,6 +1404,17 @@ var path = require('browser/path')
exports = module.exports = Mocha;
+/**
+ * To require UIs and reporters when running in node.
+ */
+
+if (process && typeof process.cwd === 'function') {
+ var join = path.join
+ , cwd = process.cwd();
+ module.paths.push(cwd, join(cwd, 'node_modules'));
+}
+
+
/**
* Expose internals.
*/