-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix(snapshot)!: fail test with obsolete snapshot on CI #7963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(snapshot)!: fail test with obsolete snapshot on CI #7963
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
| this.workerState.config.snapshotOptions.updateSnapshot === 'none' | ||
| && result.unchecked | ||
| ) { | ||
| const error = new Error(`Obsolete snapshots found: ${result.uncheckedKeys.join(', ')}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can print it in a better way (should we? obsolete snapshots are already printed one line at a time, but without the separation by test file)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tweaked the error message. Please check the example in the PR description. It's mostly a copy of the base reporter.
|
We also need to add this to migration guide |
Description
example
$ CI=1 TEST_OBSOLETE=1 pnpm -C test/snapshots test:fixtures --root test/fixture s/obsolete ... RUN v3.2.0-beta.1 /home/hiroshi/code/others/vitest/test/snapshots/test/fixtures/obsolete ✓ src/test2.test.ts (2 tests) 2ms ❯ src/test1.test.ts (3 tests) 2ms ✓ foo 1ms ✓ fuu 0ms ✓ bar 1ms ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ FAIL src/test1.test.ts [ src/test1.test.ts ] Error: Obsolete snapshots found when no snapshot update is expected. · foo 1 · fuu 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ Snapshots 2 obsolete ↳ src/test1.test.ts · foo 1 · fuu 1 Test Files 1 failed | 1 passed (2) Tests 5 passed (5) Start at 09:00:48 Duration 205ms (transform 29ms, setup 0ms, collect 29ms, tests 4ms, environment 0ms, prepare 94ms) ELIFECYCLE Command failed with exit code 1.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.