Skip to content

Flaky test marking and retrying #1057

@lukasholzer

Description

@lukasholzer

Clear and concise description of the problem

Often some tests tend to be flaky which is a nightmare in large CI/CD pipelines as you have to retrigger and rerun.

There is not always the time to fix those flaky tests (what would be the ideal case - no doubt)
But in reality it happens.

It would be nice to have a retry mechanism that does not block CI runs.

Suggested solution

I propose a feature that would mark tests as flaky (and then it would retry them up to a max that is specified when it fails)

like:

test.flaky('This test is marked as flaky', () => { /* some flaky logic */ })

in the vitest.config.ts it could be then configured how often a flaky test should be retried on failure (default to 3 times)

/// <reference types="vitest" />
import { defineConfig } from 'vite';

export default defineConfig({
  test: {
    flakyTestRetries: 4, // default would be 3
  },
})

the test would then be rerun if it fails up to the maximum specified.

It would only do that for tests that are marked as test.flaky (Therefore it needs an incentive of the user to say this test is really flaky I know but I don't have time to fix it now)

In the summary of the end it could then be written 3 flaky tests detected in addition to how many are passed or skipped.

Alternative

Not implement this feature

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions