A fixture whose setup throws is never set up again
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- testing
Research direction
Start with packages/vitest/src/runtime/runner/fixture.ts and run the linked reproduction with npm install followed by npx vitest run. Trace fixture setup caching for test, file, and worker scopes, then verify that a failed setup is retried and does not remain cached for later tests, including with isolate: false.
Written by the indexing model from the issue text.
Description
Describe the bug
If a fixture's setup throws, Vitest keeps treating the fixture as resolved and never runs the setup again.
let attempts = 0
const flaky = test.extend({
value: async ({}, use) => {
if (attempts++ === 0) throw new Error('setup failed once')
await use('ready')
},
})
flaky('x', { retry: 1 }, ({ value }) => {
expect(value).toBe('ready') // retry gets undefined
})
For test scope, withFixtures marks the fixture in cachedFixtures before awaiting setup and only unmarks it after success. The retry sees the mark, skips setup, and the test gets undefined.
For file and worker scope, the in-flight promise is cached and only deleted in a .then. A rejection stays cached and is handed to every later test, across files under isolate: false.
Both are in packages/vitest/src/runtime/runner/fixture.ts, since e53854fcc (#9550). I have a fix and tests, and will open a PR.
Reproduction
https://github.com/hamed-bavar/vitest-fixture-failed-setup
After npm install, npx vitest run fails on the retry with expected 1 to be 2: setup ran once and the retry skipped it.
System Info
System:
OS: Windows 11 10.0.26200
CPU: (12) x64 AMD Ryzen 5 7535HS with Radeon Graphics
Memory: 12.66 GB / 31.24 GB
Binaries:
Node: 22.18.0
Yarn: 1.22.22
npm: 10.9.3
pnpm: 11.24.0
Browsers:
Chrome: 152.0.7977.65
Edge: Chromium (152.0.4191.53)
Firefox: 155.0
npmPackages:
vitest: 5.0.0 => 5.0.0
Used Package Manager
npm
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.
- Dominant language
- TypeScript
- Stars
- 17.1k
- Forks
- 2k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 92
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.
More from vitest-dev/vitest
-
pending triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
vitest-dev/vitest#11276 · 3 reactions ·
-
p3-minor-bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
vitest-dev/vitest#11144 · 1 comment ·
-
pending triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
vitest-dev/vitest#11019 · 5 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
vitest-dev/vitest#10940 ·
-
p2-nice-to-have
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
vitest-dev/vitest#10793 · 1 comment ·
All issues in vitest-dev/vitest
Similar issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
vercel/react-tweet#225 ·