Skip to content

Commit 0e5ab8d

Browse files
author
Edward Drapkin
committed
Allow passthrough arguments using DETOX_TEST_RUNNER_FLAGS
1 parent b0e3b0f commit 0e5ab8d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

detox/local-cli/detox-test.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ function run() {
8989
}
9090
}
9191

92+
function collectExtraArgs() {
93+
if (process.env.DETOX_TEST_RUNNER_FLAGS) {
94+
return (process.env.DETOX_TEST_RUNNER_FLAGS + '').trim();
95+
} else {
96+
return '';
97+
}
98+
}
99+
92100
function getConfigFor(keys, fallback) {
93101
for (let i = 0; i < keys.length; i++) {
94102
const key = keys[i];
@@ -123,7 +131,7 @@ function runMocha() {
123131
const binPath = path.join('node_modules', '.bin', 'mocha');
124132
const command = `${binPath} ${testFolder} ${configFile} ${configuration} ${loglevel} ${color} ` +
125133
`${cleanup} ${reuse} ${debugSynchronization} ${platformString} ${headless} ` +
126-
`${logs} ${screenshots} ${videos} ${artifactsLocation} ${deviceName}`;
134+
`${logs} ${screenshots} ${videos} ${artifactsLocation} ${deviceName} ${collectExtraArgs()}`;
127135

128136
console.log(command);
129137
cp.execSync(command, {stdio: 'inherit'});
@@ -135,7 +143,7 @@ function runJest() {
135143
const platformString = platform ? shellQuote(`--testNamePattern=^((?!${getPlatformSpecificString(platform)}).)*$`) : '';
136144
const binPath = path.join('node_modules', '.bin', 'jest');
137145
const color = program.color ? '' : ' --no-color';
138-
const command = `${binPath} ${testFolder} ${configFile}${color} --maxWorkers=${program.workers} ${platformString}`;
146+
const command = `${binPath} ${testFolder} ${configFile}${color} --maxWorkers=${program.workers} ${platformString} ${collectExtraArgs()}`;
139147
const detoxEnvironmentVariables = {
140148
configuration: program.configuration,
141149
loglevel: program.loglevel,

docs/APIRef.DetoxCLI.md

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Initiating your test suite
6262
| -w, --workers | [iOS Only] Specifies number of workers the test runner should spawn, requires a test runner with parallel execution support (Detox CLI currently supports Jest) |
6363
| -n, --device-name [name] | Override the device name specified in a configuration. Useful for running a single build configuration on multiple devices. |
6464
> NOTE: such log levels as `silly` and `wss` are deprecated since detox@8.1.0 and will be removed in 9.0.0.
65+
> NOTE: extra arguments to the test runner (either Jest or Mocha) can be passed through using the DETOX_TEST_RUNNER_FLAGS environment variable
6566
6667
### build
6768
Run a command defined in 'configuration.build'

0 commit comments

Comments
 (0)