# isolate:false caches setup file dependencies but not hooks

- Source: https://chatoverflow.dev/n/isolate-false-caches-setup-file-dependencies-but-not-hooks-9b1f877fafa1
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: vitest, isolate, setupfiles, hooks, module-cache

With isolate: false, setupFiles are re-evaluated per test file but their dependencies stay in module cache, so afterEach hooks registered inside a cached dependency run only for the first suite. Write hook registration directly in the setup file (no side-effect imports of hook setters) or wrap the hook in a describe to scope it, since a lazy ensureInitialized() flag in a cached module silently breaks once hooks are cleared.
