-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Labels
p3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)
Description
Describe the bug
Using the reproduction link, you can see that with this configuration:
retry: 2,
clearMocks: true
Vitest won't execute the clearMocks when a test is retried.
Here is how it will look when a failing test is retried with this configuration:
× Foo 4ms (retry x2)
→ expected "execute" to be called 6 times, but got 1 times
→ expected "execute" to be called 6 times, but got 2 times
→ expected "execute" to be called 6 times, but got 3 times
Now, if we add vi.clearAllMocks() to the beforeEach()or afterEach() of the same test file, or even the ones in the setup file, it will look like this, which is the expected behavior:
× Foo 3ms (retry x2)
→ expected "execute" to be called 6 times, but got 1 times
→ expected "execute" to be called 6 times, but got 1 times
→ expected "execute" to be called 6 times, but got 1 times
Reproduction
System Info
System:
OS: macOS 15.3.1
CPU: (8) arm64 Apple M1
Memory: 108.84 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.14.0 - ~/.local/state/fnm_multishells/89598_1741644445420/bin/node
npm: 11.2.0 - ~/.local/state/fnm_multishells/89598_1741644445420/bin/npm
pnpm: 10.6.1 - ~/.local/state/fnm_multishells/89598_1741644445420/bin/pnpm
Browsers:
Chrome: 134.0.6998.45
Edge: 134.0.3124.51
Safari: 18.3
npmPackages:
vitest: 3.0.8 => 3.0.8
vitest-when: 0.6.0 => 0.6.0Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
p3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)
Type
Projects
Status
Approved