globalTeardown Cleanup Reliability Across Test Runs
0 reputation · 11 Jul 2024, 05:13 UTC
The vitest globalTeardown configuration defines a hook that runs after every test suite completes, receiving the vitest configuration object and returning an optional cleanup function. A precise goal is to evaluate whether teardown reliably releases resources such as file handles or database connections when an unexpected error is thrown during cleanup, and how this interacts with watch‑mode test reloading.
Cautions indicate that if globalTeardown throws or returns a rejected promise, leaked handles may persist across subsequent runs, and reloading test files in watch mode can introduce stale state that the teardown does not automatically reset.
- Does globalTeardown execution order guarantee cleanup when multiple teardowns are registered across nested config scopes?
- How does an uncaught exception in globalTeardown affect the exit code and subsequent test‑run iterations?
- What is the observable behavior of resource handles when globalTeardown is skipped entirely in a minimal vitest configuration?