Jest: [Feature] Include obsolete snapshots info in json output

Created on 2 Nov 2016  Â·  8Comments  Â·  Source: facebook/jest

Do you want to request a feature or report a bug?
Feature

What is the current behavior?
If one wants to check if there are any obsolete snapshots, one must parse the human readable command output.

What is the expected behavior?
I reckon the info should be included in the --json output.

Also it might make sense if there was a switch that made the existence of obsolete snapshots cause jest to exit with an error. The use case I personally see is having a git hook to prevent me from accidentally committing obsolete snapshots.

Enhancement

Most helpful comment

Having the same issue with our project build on Jenkins, though on local dev env everything is ok.
All tests are passed, there are skipped tests, but still getting › 1 obsolete snapshot file found, run with `npm run jest -- -u` to remove it. error.

All 8 comments

Hmm, I'm also having trouble with obsolete. I see 1 obsolete snapshot found in the snapshot summary but it does not say which file or snapshot is causing that.

I was hoping we could change Jest so that it actually fails the test itself when something is obsolete.

Yeah, no way to understand what's wrong (example — https://circleci.com/gh/electron-userland/electron-builder/447?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link)

It seems Jest doesn't detect that actually test is just skipped/ignored.

@develar do you think you could help with a PR? This data could be added here: https://github.com/cpojer/jest/blob/e4220e6659abdc4d6d4500455eb4982d3230dba3/packages/jest-jasmine2/src/index.js#L97

and we could add the testExecError to make it print the proper error.

Having the same issue with our project build on Jenkins, though on local dev env everything is ok.
All tests are passed, there are skipped tests, but still getting › 1 obsolete snapshot file found, run with `npm run jest -- -u` to remove it. error.

this error is really annyoing

@adaniliuk I saw this error today but in my case it was because my build process was copying the .snap file from my src directory to my lib directory so there was in fact an extra .snap file in the entire project during the CI build. I fixed my build to not copy the .snap file and build is green again.

Obsolete snapshots are reproted as "unchecked" in JSON output. Also, the snapshot summary was recently overhauled by @rickhanlonii https://github.com/facebook/jest/pull/6181, will be available in Jest 23 :)

Was this page helpful?
0 / 5 - 0 ratings