Skip to content

Commit

Permalink
Refactor setting config from argv (#3424)
Browse files Browse the repository at this point in the history
* Rename setState to updateArgv

* Add Argv type

* Remove unnecessary argv.help check

* Refactor setting config from argv

* Rename acc to options

* Use dot notation instead of string keys

* Make Options of updateArgv an exact type

* Move Argv type to it's own file

* Update showConfig snapshot with 'projects'

* Add missing options to args

* Update setFromArgv and Argv types

* Extract and reuse isJSON

* Update updateArgv.js

* Update validateCLIOptions.js

* Move regex check out of _replaceRootDirInObject

* Make explicit flags override those from --config

* Rename isJSON -> isJSONString

* Add reporters to args
  • Loading branch information
thymikee authored and cpojer committed May 2, 2017
1 parent 4a99428 commit 062edb0
Show file tree
Hide file tree
Showing 19 changed files with 485 additions and 186 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ exports[`jest --showConfig outputs config info and exits 1`] = `
"mapCoverage": false,
"noStackTrace": false,
"notify": false,
"projects": [
"/mocked/root/path/jest/integration_tests/verbose_reporter"
],
"rootDir": "/mocked/root/path/jest/integration_tests/verbose_reporter",
"testPathPattern": "",
"testResultsProcessor": null,
Expand Down
10 changes: 10 additions & 0 deletions integration_tests/__tests__/config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ test('works with sane config JSON', () => {
});

test('watchman config option is respected over default argv', () => {
const {stdout} = runJest('verbose_reporter', [
'--env=node',
'--watchman=false',
'--debug',
]);

expect(stdout).toMatch('"watchman": false');
});

test('config from argv is respected with sane config JSON', () => {
const {stdout} = runJest('verbose_reporter', [
'--config=' +
JSON.stringify({
Expand Down
4 changes: 3 additions & 1 deletion integration_tests/__tests__/coverage_report-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ test('outputs coverage report as json', () => {
try {
JSON.parse(stdout);
} catch (err) {
throw new Error("Can't parse the JSON result from stdout" + err.toString());
throw new Error(
"Can't parse the JSON result from stdout. " + err.toString(),
);
}
});
4 changes: 1 addition & 3 deletions integration_tests/runJest.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ function runJest(dir, args) {
);
}

const result = spawnSync(JEST_PATH, args || [], {
cwd: dir,
});
const result = spawnSync(JEST_PATH, args || [], {cwd: dir});

result.stdout = result.stdout && result.stdout.toString();
result.stderr = result.stderr && result.stderr.toString();
Expand Down
Loading

0 comments on commit 062edb0

Please sign in to comment.