-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Labels
good first issueGood for newcomersGood for newcomersp2-nice-to-haveNot breaking anything but nice to have (priority)Not breaking anything but nice to have (priority)
Description
Clear and concise description of the problem
Vitest supports a retry
mechanism, but currently it only retries a fixed number of times on any kind of error.
This limits flexibility in several ways:
- It’s not possible to retry only on specific error types (e.g.
TimeoutError
). - There is no option to delay retries (useful for APIs, DBs, or rate-limited services).
- There is no option to defer retries until the end of the test file, which can improve flow and reduce interference with other tests.
Other test runners (e.g. Jest, WebdriverIO) provide these options:
- Webdriver.io and their
specFileRetriesDelay
+specFileRetriesDeferred
option. - Jest and the
retryTimes(numRetries, { waitBeforeRetry: 100, retryImmediately: false })
function.
Suggested solution
Extend the retry
API with the following features:
-
retryStrategy: "immediate" | "test-file" | "deferred"
(defaultimmediate
)immediate
: retry failed test immediately.test-file
: run retries until the end of the test file.deferred
: defer retries after all other tests have run across all test files.
-
retryDelay: number
(milliseconds, default0
). Or even better, use Add Support for Backoff Mechanism in Retry Configuration #8095 -
retryCondition: string | ((error: Error) => boolean)
: Ifstring
(Regexp), it should only retry when the occurredError
message matches the Regexp. If function, it should only retry when the function returnstrue
.
Alternative
No response
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomersp2-nice-to-haveNot breaking anything but nice to have (priority)Not breaking anything but nice to have (priority)
Type
Projects
Status
Approved