diff --git a/detox/local-cli/detox-test.js b/detox/local-cli/detox-test.js index fac9b7cb0f..bde8a4a911 100644 --- a/detox/local-cli/detox-test.js +++ b/detox/local-cli/detox-test.js @@ -24,21 +24,29 @@ program .option('-p, --platform [ios/android]', 'Run platform specific tests. Runs tests with invert grep on \':platform:\', ' + 'e.g test with substring \':ios:\' in its name will not run when passing \'--platform android\'') + .option('-f, --file [path]', + 'Specify test file to run') .parse(process.argv); const config = require(path.join(process.cwd(), 'package.json')).detox; -const testFolder = getConfigFor('specs', 'e2e'); -const runner = getConfigFor('testRunner', 'mocha'); -const runnerConfig = getConfigFor('runnerConfig', getDefaultRunnerConfig()); +const testFolder = getConfigFor(['file', 'specs'], 'e2e'); +const runner = getConfigFor(['testRunner'], 'mocha'); +const runnerConfig = getConfigFor(['runnerConfig'], getDefaultRunnerConfig()); if (typeof program.debugSynchronization === "boolean") { program.debugSynchronization = 3000; } -function getConfigFor(key, defaults) { - const keyKebabCase = camelToKebabCase(key); - return program[key] || config[key] || config[keyKebabCase] || defaults; +function getConfigFor(keys, fallback) { + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const keyKebabCase = camelToKebabCase(key); + const result = program[key] || config[key] || config[keyKebabCase]; + if (result) return result; + } + + return fallback; } function camelToKebabCase(string) {