vitest-dev / vitest-dev/vitest

Vitest incorrectly retries the `it.fails` tests

Open
#11,068 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

p3-minor-bug
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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.