Vitest retry feature and file‑system write operations: handling duplicate writes
0 reputation · 18 Jan 2024, 15:21 UTC
When a Vitest test is marked with retry: n, the framework re‑executes the entire test function on each attempt, including any setup code that performs file‑system writes such as snapshot creation or log output. This behavior can produce duplicate writes if the test writes to the same path on every retry, potentially corrupting artifacts or causing noisy CI logs. The current documentation does not describe a built‑in way to isolate or reset side‑effects between retry attempts, leaving users to manage cleanup manually in hooks like beforeEach or afterEach.
- Does Vitest provide a hook that runs between retry attempts to clean up side‑effects?
- Can the retry mechanism be limited to re‑running only the assertion portion of a test without re‑executing setup?
- Is there an ongoing proposal or planned feature to add automatic side‑effect isolation for retries?