Skip to content

Commit

Permalink
feat(jest): allow passthrough of any Jest cli params
Browse files Browse the repository at this point in the history
  • Loading branch information
evansiroky committed Jul 3, 2019
1 parent 0281213 commit fb2a38e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ Options:
-u, --update-snapshots Force update of snapshots. USE WITH CAUTION.
--coverage Run Jest with coverage reporting
--coverage-paths <paths> Extra paths to collect code coverage from
--json-output-file <path> Export a json report of the tests to the path
--jest-cli-args <args> Extra arguments to pass directly to the Jest Cli. Make sure to encapsulate all extra arguments in quote
--no-cache Run Jest without cache (defaults to using cache)
--run-in-band Run all tests serially in the current process
--setup-files <paths> Setup files to run before each test
Expand Down
5 changes: 4 additions & 1 deletion bin/mastarm-test
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ commander
'Extra paths to collect code coverage from'
)
.option('--force-exit', 'Force Jest to exit after all tests have completed running.')
.option('--json-output-file <path>', 'Output Jest test results to this file')
.option(
'--jest-cli-args <args>',
'Extra arguments to pass directly to the Jest Cli. Make sure to encapsulate all extra arguments in quotes'
)
.option('--no-cache', 'Run Jest without cache (defaults to using cache)')
.option('--run-in-band', 'Run all tests serially in the current process')
.option('--setup-files <paths>', 'Setup files to run before each test')
Expand Down
9 changes: 4 additions & 5 deletions lib/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ module.exports.generateTestConfig = (patterns, options) => {
jestArguments.push('--forceExit')
}

if (options.jsonOutputFile) {
jestArguments.push('--json')
jestArguments.push(`--outputFile=${options.jsonOutputFile}`)
}

if (options.updateSnapshots) {
jestArguments.push('--updateSnapshot')
}
Expand All @@ -77,6 +72,10 @@ module.exports.generateTestConfig = (patterns, options) => {

jestArguments.push('--config', JSON.stringify(jestConfig))

if (options.jestCliArgs) {
jestArguments = jestArguments.concat(...options.jestCliArgs.split(' '))
}

if (patterns) {
jestArguments = jestArguments.concat(patterns)
}
Expand Down

0 comments on commit fb2a38e

Please sign in to comment.