Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a good report for jest test case?

Tags:

jestjs

I am using jest to test my reactjs application. It works fine but jest doesn't give me a good report about test case results. The output of jest shows each test suite followed by its output. I have more than 50 test suites and it is hard for me to scroll up to check each failed test cases. Is there a brief jest report which printing a brief summary about the whole test cases? below is my jest.conf file:

{
  "testRegex": "/tests/.*\\.test\\.jsx?$",
  "testEnvironment": "node",
  "roots": ["./src"],
  "coverageReporters": ["text-summary", "html"]
}
like image 503
Joey Yi Zhao Avatar asked May 05 '17 00:05

Joey Yi Zhao


People also ask

Is Jest enough for testing?

Jest is a JavaScript test runner that lets you access the DOM via jsdom . While jsdom is only an approximation of how the browser works, it is often good enough for testing React components.

What is Jest coverage report?

Jest: Coverage Report. Popular JavaScript frameworks can use Facebook's Jest to perform unit tests. Jest has the Coverage Report feature that allows us to check if our code covers all lines of the files we choose by generating an HTML file that we can open.

What is Jest good for?

Jest is a JavaScript testing framework designed to ensure correctness of any JavaScript codebase. It allows you to write tests with an approachable, familiar and feature-rich API that gives you results quickly. Jest is well-documented, requires little configuration and can be extended to match your requirements.


3 Answers

There is also a JEST HTML Reporter module which you might find useful. It's configurable to specify what level of detail you want to show in the test report for failures

https://www.npmjs.com/package/jest-html-reporter

like image 199
Dave Gordon Avatar answered Dec 01 '22 15:12

Dave Gordon


You can run jest with the --coverage flag.

If you want something different than the default reporters, you have to set them in your jest config file.

jest.json

{
  "coverageReporters": ["text-summary", "html"]
}

text-summary gives you a short summary beneath all tests that tells you how many suites/tests are successful/failed.

html gives you a some html pages that you can browse through to see exactly what got tested.

CLI

$ ./node_modules/.bin/jest --config ./path/to/jest.json --coverage

You might want to adjust which files are covered etc. See all coverage options in the jest docs.

like image 45
publicJorn Avatar answered Dec 01 '22 14:12

publicJorn


https://github.com/jest-community/awesome-jest#reporters contains a list of other reporters. jest-stare will let you filter off passing tests so you can just see the ones that failed.

like image 25
dkelosky Avatar answered Dec 01 '22 15:12

dkelosky