Is there a good report for jest test case?

Multi tool use
Is there a good report for jest test case?
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:
jest
jest
jest
jest
jest.conf
{
"testRegex": "/tests/.*\.test\.jsx?$",
"testEnvironment": "node",
"roots": ["./src"],
"coverageReporters": ["text-summary", "html"]
}
2 Answers
2
You can run jest with the --coverage
flag.
--coverage
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.
text-summary
html
gives you a some html pages that you can browse through to see exactly what got tested.
html
CLI
$ ./node_modules/.bin/jest --config ./path/to/jest.json --coverage
$ ./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.
I see you have added the
roots
option. This may influence the results. Try adding the collectCoverageFrom
option and maybe one of the other coverage options. On a sidenote, it's usually better to keep your "roots" relative to rootDir
, using "<rootDir>"– publicJorn
May 6 '17 at 8:53
roots
collectCoverageFrom
rootDir
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
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I have tried this option but it doesn't show the report. I have posted my jest.conf file.
– Zhao Yi
May 5 '17 at 12:36