Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make Jest not show me a summary of all the skipped tests?

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.

enter image description here

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.

like image 917
mikemaccana Avatar asked Mar 06 '20 16:03

mikemaccana


People also ask

How do I get rid of console log from Jest?

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.

How do you only run one test in Jest?

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.

How do I avoid console error in Jest?

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.


1 Answers

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
  }
}

like image 193
Teneff Avatar answered Oct 13 '22 04:10

Teneff