I frequently run a single test, either with it.only
or test.only
or with the --testPathPattern='somepattern'
options. I'll often watch the output in my terminal.
When I do, I can't see the output from my particular test, because Jest insists on showing me a summary of all the tests I skipped.
This goes on for many pages, hiding the test output I am trying to watch.
How can I stop jest from telling me the names of all the tests I skipped?
I've looked in the Jest config guide but can't find the option.
To disable console inside unit tests with Jest, we can use the --silent option or set the console methods to mocked functions. to run jest with the --silient to disable console output when running tests.
It's in the Jest documentation. Another way is to run tests in watch mode, jest --watch , and then press P to filter the tests by typing the test file name or T to run a single test name.
Here is my current approach: describe("Some description", () => { let consoleSpy; beforeEach(() => { if (typeof consoleSpy === "function") { consoleSpy. mockRestore(); } }); test("Some test that should not output errors to jest console", () => { expect. assertions(2); consoleSpy = jest.
You set displaying the "individual test results with the test suite hierarchy" with the verbose option, but it's boolean and can't be disabled for the skipped tests only.
Whenever you're running only specific tests you can pass:
cli (npm)
npm test -- --testPathPattern='somepattern' --verbose=false
cli (yarn)
yarn test --testPathPattern='somepattern' --verbose=false
or disable it from the configuration, which you probably wouldn't want
package.json
(a bit more permanent){
//...
"jest": {
"verbose": false
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With