vitest: Updating snapshots doesn't remove obsolete ones
Describe the bug
For a .tsx
file with snapshot tests, if a new snapshot is added and later removed this then becomes an “obsolete” snapshot. In the interactive terminal when using Vitest’s watch mode, pressing u
to update snapshots does not remove obsolete ones. In Jest, u
does two things: update existing snapshots, and remove obsolete ones.
When pressing u
Vitest prints Re-running tests... [ update snapshot ]
but nothing happns.
The workaround is to delete the obsolete snapshots manually.
Reproduction
Repro: https://stackblitz.com/edit/node-jhjpur?file=src%2Fcomponents%2FButton.test.tsx
System Info
System:
OS: macOS 11.6.2
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 43.79 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.0 - /usr/local/bin/node
Yarn: 1.22.17 - ~/.yarn/bin/yarn
npm: 8.1.2 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Browsers:
Chrome: 98.0.4758.80
Edge: 98.0.1108.43
Firefox: 96.0.3
Firefox Developer Edition: 79.0
Safari: 15.3
Safari Technology Preview: 15.4
npmPackages:
@vitejs/plugin-react: ^1.1.4 => 1.1.4
vite: ^2.7.13 => 2.7.13
vitest: ^0.2.7 => 0.2.7
### Used Package Manager
yarn
### Validations
- [X] Follow our [Code of Conduct](https://github.com/vitest-dev/vitest/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/vitest-dev/vitest/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://vitest.dev/guide).
- [X] Check that there isn't [already an issue](https://github.com/vitest-dev/vitest/issues) that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitest-dev/vitest/discussions) or join our [Discord Chat Server](https://chat.vitest.dev).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 15 (1 by maintainers)
Same issue using
0.15.1
@sheremet-va Unfortunately, I can still reproduce this on
0.5.0
.See here: https://stackblitz.com/edit/node-qtcaat?file=src%2Fcomponents%2FButton.test.tsx