setup-node: Test workflow is failing with Jest snapshot errors
Test workflow is failing with Jest snapshot errors saying they are not up-to-date - but the updated snapshots have been checked in and the tests pass locally after a clean build.
Github CI run
$ jest --coverage --ci
...
Snapshot Summary
› 11 snapshots failed from 4 test suites. Inspect your code changes or run `yarn test -u` to update them.
Test Suites: 4 failed, 3 passed, 7 total
Tests: 11 failed, 27 passed, 38 total
Snapshots: 11 failed, 7 passed, 18 total
Time: 5.62 s
Local run of the same branch with no other changes
$ jest --coverage --ci
...
Test Suites: 7 passed, 7 total
Tests: 38 passed, 38 total
Snapshots: 18 passed, 18 total
Time: 5.852 s
- checked out the branch to a diff clean location in my machine and tried out the CI commands - no issues 😕
- tried running the build locally in ubuntu container - runs fine without any issues
- switching to mac-os from ubuntu for the workflow doesn’t fix the issue 😦
- Resolved this issue by switching to CircleCi. Tests all pass now.
Reporting here because I like Github actions and would like to continue using it.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 16
- Comments: 17 (3 by maintainers)
I’m having a similar issue with typescript, same node version, npm, and typescript on my local machine than the ci machine, when i run the ci, i’m seeing errors that on my local machine doesn’t appear.
@IvanZosimov I did, thanks for the ping. It was in fact the color. Github actions run with no color output, but my terminal does. Therefore, the snapshot generated by the action didn’t match. I added this from the Stack Overflow answer:
That solved the problem for me.
Hello guys, Due to the fact that everything seems to be working now, I will close this issue. If you still experience any issues, feel free to leave a comment here or to create a new issue.
In case someone has renamed the filenames that may not been updated Linux takes things case sensitive by mac os doesn’t Either remove snapshots and run all test cases or manually change snapshot file name
FWIW I was also debugging this for my CI build. My
npm test
just ran this:What was interesting was the
git status
:So I’m guessing this issue is a bug in jest related to casing – as you can see, the version of Jest I created the snapshot with downcast the file name, even though the tested file was capitalized.
It’s very similar to https://github.com/facebook/jest/issues/9865 and https://github.com/facebook/jest/issues/8900 but I think it’s its own issue.
The good news (for me at least), was that fixing the casing discrepancy fixed the issue, and the latest version of Jest generated files with the correct casing (could have been updating, could have been me switching from Intel to ARM for dev – who knows). So if you come to this issue via search, I’d check out these possible solutions.
@misterrodger You may be aware of this, but running Github Actions with a macOS runner costs 10x that of using the Linux runner. It’s awesome you found a fix for your issue, but worth calling out the cost difference - you’ll eat up your Github minutes much, much faster.
https://docs.github.com/en/github/setting-up-and-managing-billing-and-payments-on-github/about-billing-for-github-actions