From 744c4266e8ee00562d06836143749e74901e4049 Mon Sep 17 00:00:00 2001 From: Jeremy Eaton Date: Fri, 9 Mar 2018 18:32:46 -0800 Subject: [PATCH 1/2] add -f option to run specific test file --- detox/local-cli/detox-test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/detox/local-cli/detox-test.js b/detox/local-cli/detox-test.js index fac9b7cb0f..b16a1719b5 100644 --- a/detox/local-cli/detox-test.js +++ b/detox/local-cli/detox-test.js @@ -24,11 +24,13 @@ 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 testFolder = getConfigFor('file', 'specs', 'e2e'); const runner = getConfigFor('testRunner', 'mocha'); const runnerConfig = getConfigFor('runnerConfig', getDefaultRunnerConfig()); From 660df9c8d9b605a580a8191064847dbc6e20478f Mon Sep 17 00:00:00 2001 From: Jeremy Eaton Date: Sun, 11 Mar 2018 16:09:50 -0700 Subject: [PATCH 2/2] extend getConfigFor to support multiple keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and use “fallback” instead of “defaults” because it’s singular and not a keyword --- detox/local-cli/detox-test.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/detox/local-cli/detox-test.js b/detox/local-cli/detox-test.js index b16a1719b5..bde8a4a911 100644 --- a/detox/local-cli/detox-test.js +++ b/detox/local-cli/detox-test.js @@ -30,17 +30,23 @@ program const config = require(path.join(process.cwd(), 'package.json')).detox; -const testFolder = getConfigFor('file', '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) {