Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix behavior of --silent flag #3003

Merged
merged 1 commit into from
Feb 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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