repeats
- Type:
number - Default:
0 - CLI:
--repeats=<number>
Repeat every test a specific number of times regardless of the result. A test that uses the repeats test option takes precedence over this value.
This is useful for verifying that tests are stable across multiple runs. If a test fails on any repetition, the whole test is reported as failed. A failure that reaches the bail limit stops the next repeats. If a repeat calls skip(), Vitest skips only this repeat. The test is skipped only if all of its repeats are skipped.
Each repeat gets its own seed for context.random and vi.useFakeRandom. See Seeded Tests.
Because the test option takes precedence, --repeats does not change a test with its own repeats. To run more repeats of some tests in one CI job, set repeats on a tag in the config instead of on the tests:
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
tags: [
{ name: 'simulation', repeats: process.env.NIGHTLY ? 1999 : 99 },
],
},
})