Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f3fc91c

Browse files
committedFeb 25, 2017
Fix behavior of --silent flag
1 parent 445663b commit f3fc91c

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed
 

‎integration_tests/__tests__/__snapshots__/console-test.js.snap

+18
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,21 @@ Time: <<REPLACED>>
5757
Ran all test suites.
5858
"
5959
`;
60+
61+
exports[`does not print to console with --silent 1`] = `""`;
62+
63+
exports[`does not print to console with --silent 2`] = `
64+
" PASS __tests__/console-test.js
65+
✓ works just fine
66+
67+
"
68+
`;
69+
70+
exports[`does not print to console with --silent 3`] = `
71+
"Test Suites: 1 passed, 1 total
72+
Tests: 1 passed, 1 total
73+
Snapshots: 0 total
74+
Time: <<REPLACED>>
75+
Ran all test suites.
76+
"
77+
`;

‎integration_tests/__tests__/console-test.js

+18
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,21 @@ test('console printing with --verbose', () => {
3434
expect(rest).toMatchSnapshot();
3535
expect(summary).toMatchSnapshot();
3636
});
37+
38+
test('does not print to console with --silent', () => {
39+
const {stderr, stdout, status} =
40+
runJest('console', [
41+
// Need to pass --config because console test specifies `verbose: false`
42+
'--config=' + JSON.stringify({
43+
testEnvironment: 'node',
44+
}),
45+
'--silent',
46+
'--no-cache',
47+
]);
48+
const {summary, rest} = extractSummary(stderr);
49+
50+
expect(status).toBe(0);
51+
expect(stdout).toMatchSnapshot();
52+
expect(rest).toMatchSnapshot();
53+
expect(summary).toMatchSnapshot();
54+
});

‎packages/jest-cli/src/runJest.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ const runJest = (
8686
}
8787
return data;
8888
}).then(data => {
89-
if (data.paths.length === 1 && config.verbose !== false) {
90-
// $FlowFixMe
91-
config = Object.assign({}, config, {verbose: true});
89+
if (data.paths.length === 1) {
90+
if (config.silent !== true && config.verbose !== false) {
91+
// $FlowFixMe
92+
config = Object.assign({}, config, {verbose: true});
93+
}
9294
}
9395

9496
return new TestRunner(

0 commit comments

Comments
 (0)
Please sign in to comment.