Skip to content

Commit

Permalink
Fix behavior of --silent flag (jestjs#3003)
Browse files Browse the repository at this point in the history
  • Loading branch information
wyze authored and skovhus committed Apr 29, 2017
1 parent 64eba7e commit bb0c74f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
17 changes: 17 additions & 0 deletions integration_tests/__tests__/__snapshots__/console-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,20 @@ Time: <<REPLACED>>
Ran all test suites.
"
`;
exports[`does not print to console with --silent 1`] = `""`;
exports[`does not print to console with --silent 2`] = `
" PASS __tests__/console-test.js
"
`;
exports[`does not print to console with --silent 3`] = `
"Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: <<REPLACED>>
Ran all test suites.
"
`;
18 changes: 18 additions & 0 deletions integration_tests/__tests__/console-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,21 @@ test('console printing with --verbose', () => {
expect(rest).toMatchSnapshot();
expect(summary).toMatchSnapshot();
});

test('does not print to console with --silent', () => {
const {stderr, stdout, status} =
runJest('console', [
// Need to pass --config because console test specifies `verbose: false`
'--config=' + JSON.stringify({
testEnvironment: 'node',
}),
'--silent',
'--no-cache',
]);
const {summary, rest} = extractSummary(stderr);

expect(status).toBe(0);
expect(stdout).toMatchSnapshot();
expect(rest).toMatchSnapshot();
expect(summary).toMatchSnapshot();
});
8 changes: 5 additions & 3 deletions packages/jest-cli/src/runJest.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ const runJest = (
}
return data;
}).then(data => {
if (data.paths.length === 1 && config.verbose !== false) {
// $FlowFixMe
config = Object.assign({}, config, {verbose: true});
if (data.paths.length === 1) {
if (config.silent !== true && config.verbose !== false) {
// $FlowFixMe
config = Object.assign({}, config, {verbose: true});
}
}

return new TestRunner(
Expand Down

0 comments on commit bb0c74f

Please sign in to comment.