vitest-dev / vitest-dev/vitest
Vitest incorrectly retries the `it.fails` tests
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 17.1k
- Forks
- 2k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 94
Description
Describe the bug
Vitest keeps retrying the test that fails and which is marked as it.fails.
Reproduction
Consider the following Vitest test:
import { expect, it } from 'vitest';
it.fails('vitest bug', { retry: 2 }, async (ctx) => {
console.log('attempt!');
expect(1).toBe(2);
});
I expect to see attempt! output only once: the test is declared as failing and it fails on the first attempt.
Instead, I see 3 attempts.
System Info
System:
OS: macOS 26.5.1
CPU: (10) arm64 Apple M1 Max
Memory: 996.88 MB / 32.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 20.20.2 - /Users/aslushnikov/fk/vitest/node_modules/.bin/node
npm: 11.17.0 - /Users/aslushnikov/.local/share/mise/installs/node/latest/bin/npm
pnpm: 11.5.0 - /Users/aslushnikov/.local/share/mise/installs/pnpm/latest/pnpm
Browsers:
Chrome: 151.0.7922.174
Safari: 26.5
npmPackages:
@vitest/browser: ^4.1.10 => 4.1.10
@vitest/browser-playwright: ^4.1.10 => 4.1.10
@vitest/utils: ^4.1.10 => 4.1.10
playwright: ^1.61.1 => 1.61.1
vitest: ^4.1.10 => 4.1.10
Used 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the TypeScript reproduction from the issue with Vitest and pnpm, observing the retry behavior for an it.fails test with { retry: 2 }. Trace the retry handling and the it.fails path, then add a regression test showing that the failing test runs once; the expected output is one attempt! line rather than three.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100