diff --git a/README.md b/README.md index 3df4a8c..e6c9b7c 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ jest-runner-mocha maps some mocha CLI arguments to config options. For example ` |ui|`"ui": "tdd"` |timeout|`"timeout": 10000` |compiler|`"compiler": "./path/to/babel-register"` +|file|`"file": ["./path/to/include.js", "/supports/multiple/files.js"`] ### Coverage diff --git a/src/runMocha.js b/src/runMocha.js index 70a5226..612da8c 100644 --- a/src/runMocha.js +++ b/src/runMocha.js @@ -56,6 +56,10 @@ const runMocha = ({ config, testPath, globalConfig }, workerCallback) => { coveragePathIgnorePatterns: config.coveragePathIgnorePatterns, }); + if (mochaOptions.file) { + mochaOptions.file.forEach(file => mocha.addFile(file)); + } + mocha.addFile(testPath); const onEnd = () => { diff --git a/src/utils/getMochaOptions.js b/src/utils/getMochaOptions.js index cfd2e7d..87cd8db 100644 --- a/src/utils/getMochaOptions.js +++ b/src/utils/getMochaOptions.js @@ -10,6 +10,17 @@ const normalize = (jestConfig, { cliOptions: rawCliOptions = {} }) => { cliOptions.compiler = path.resolve(jestConfig.rootDir, cliOptions.compiler); } + if (cliOptions.file) { + const file = [].concat(cliOptions.file); + cliOptions.file = file.map(f => { + if (path.isAbsolute(f)) { + return f; + } + + return path.resolve(jestConfig.rootDir, f); + }); + } + return { cliOptions }; };