Skip to content

Commit 331de75

Browse files
committed
Merge pull request #941 from ericpizon/master-MochaPath
- supports configuring mocha path thru mocha.json. When mocha path is…
2 parents 18f6249 + 1a17870 commit 331de75

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

  • Nodejs/Product/Nodejs/TestFrameworks/mocha

Nodejs/Product/Nodejs/TestFrameworks/mocha/mocha.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,17 @@ function logError() {
7979
}
8080

8181
function detectMocha(projectFolder) {
82-
try {
83-
var mochaPath = path.join(projectFolder, 'node_modules', 'mocha');
82+
try {
83+
var node_modulesFolder = projectFolder;
84+
var mochaJsonPath = path.join(node_modulesFolder, 'test', 'mocha.json');
85+
if (fs.existsSync(mochaJsonPath)) {
86+
var opt = require(mochaJsonPath);
87+
if (opt && opt.path) {
88+
node_modulesFolder = path.resolve(projectFolder, opt.path);
89+
}
90+
}
91+
92+
var mochaPath = path.join(node_modulesFolder, 'node_modules', 'mocha');
8493
var Mocha = new require(mochaPath);
8594
return Mocha;
8695
} catch (ex) {

0 commit comments

Comments
 (0)