Skip to content

Commit

Permalink
Add support for file cliOptions arg
Browse files Browse the repository at this point in the history
  • Loading branch information
hswolff committed Feb 9, 2018
1 parent 690a95f commit 4557469
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions src/runMocha.js
Expand Up @@ -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 = () => {
Expand Down
11 changes: 11 additions & 0 deletions src/utils/getMochaOptions.js
Expand Up @@ -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 };
};

Expand Down

0 comments on commit 4557469

Please sign in to comment.