Sometimes the output of running Jest unit tests is a bit too verbose, with the pass and fail statuses of all tests as well as the test coverage table.
To prevent outputting the code coverage report table, use:
jest --collectCoverage=false
(This assumes Jest is configured to show the code coverage report already.)
We can reduce the verbosity of the Jest output aside from the coverage table by using a custom reporter. Jest Silent Reporter is a good choice for this. To install it:
$ npm install jest-silent-reporter
Then run the tests with:
$ jest --reporters jest-silent-reporter
Now we will see only the failing test output.
The coverage report can still be shown after the silent reporter output.
So, for the minimum output possible we can combine the silent reporter and omit coverage report:
$ jest --collectCoverage=false --reporters jest-silent-reporter
We can add this command to our package.json to have the option to run a silent minimal output for all our tests easily, for example like this:
"scripts": { "unit:silent": "jest --reporters jest-silent-reporter --collectCoverage=false" }
Then we can just run:
$ npm run unit:silent
References
https://www.npmjs.com/package/jest-silent-reporter