Skip to content

Commit

Permalink
Merge pull request #616 from jeremyeaton89/test-file-flag
Browse files Browse the repository at this point in the history
add -f option to run specific test file
  • Loading branch information
rotemmiz authored Mar 14, 2018
2 parents 7bc4742 + 660df9c commit 8ac1fd9
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions detox/local-cli/detox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8ac1fd9

Please sign in to comment.