Skip to content

Vitest incorrectly retries the it.fails tests #11068

Description

@aslushnikov

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions