close
logo
Rstest
Guide
Config
API
English
简体中文
Guide
Config
API
English
简体中文
logo
Rstest
Overview

Test Configurations

root
name
include
exclude
setupFiles
projects
update
globals
passWithNoTests
includeSource
testNamePattern
env
retry
testTimeout
hookTimeout
maxConcurrency
pool
isolate
testEnvironment
clearMocks
resetMocks
restoreMocks
unstubEnvs
unstubGlobals
coverage
reporters
hideSkippedTests
slowTestThreshold
snapshotFormat
resolveSnapshotPath
printConsoleTrace
onConsoleLog
disableConsoleIntercept

Build Configurations

plugins
source
output
resolve
tools
dev
performance
📝 Edit this page on GitHub
Previous Pageenv
Next PagetestTimeout

#retry

  • Type: number
  • Default: 0
  • CLI: --retry <times>

Retry the test specific number of times if it fails. This is useful for some flaky or non-deterministic test failures.

#Example

You can get two retries by setting retry:2 when the test fails:

CLI
rstest.config.ts
import { defineConfig } from '@rstest/core';

export default defineConfig({
  retry: 2,
});

When the test has retried, you may get the following logs:

  • success:
 ✓ retry.test.ts (1)
  ✓ should run success with retry (6ms) (retry x2)

 Test Files 1 passed
      Tests 1 passed
   Duration 146 ms (build 22 ms, tests 124 ms)
  • or failure:
 ✗ retry.test.ts (1)
  ✗ should run success with retry (6ms) (retry x2)
    expected 1 to be 5 // Object.is equality
    expected 2 to be 5 // Object.is equality
    expected 3 to be 5 // Object.is equality

 ...

 Test Files 1 failed
      Tests 1 failed
   Duration 171 ms (build 23 ms, tests 148 ms)