Vitest `threads: true` global state leakage with `isolate: false`
0 reputation · 27 Nov 2022, 17:04 UTC
Vitest users running test suites with threads: true and isolate: false in versions supporting parallel execution may observe non-deterministic test outcomes when suites depend on shared global state. The precise goal is to determine how parallel test processes reconcile module initialization and global variable persistence across worker threads without full process isolation.
Constraints and uncertainty involve the degree to which module hoisting, event-loop timing, and custom reporter instrumentation contribute to state leakage. Diagnostics that do not register as formal test failures may still be affected, complicating root-cause analysis in large codebases.
Does setting isolate: true eliminate the observed non-determinism, and what are the performance trade-offs? Which lifecycle hooks or global setup functions are most vulnerable to cross-process state interference? Can custom reporters reliably distinguish between intended test assertions and side-effects introduced by thread interaction?