histoire
Version:
A fast story book powered by Vite
17 lines (16 loc) • 805 B
JavaScript
/** Reads the worker installed by Vitest or preview bootstrap. */
export function getVitestWorkerState() {
return globalThis.__vitest_worker__;
}
/** Only isolated browser specs with confirmed teardown can retain the discovery mount. */
export function getVitestBrowserMountCleanups() {
// Vitest drains these cleanups from the tester finalizer. Browser isolation
// moved from browser.isolate in v4 to the shared isolate option in v5.
const state = globalThis.__vitest_browser_runner__;
const config = state?.config;
if (!Array.isArray(state?.cleanups) || !(config?.browser?.isolate ?? config?.isolate))
return;
if (config.clearMocks || config.mockReset || config.restoreMocks || config.unstubEnvs || config.unstubGlobals)
return;
return state.cleanups;
}