UNPKG

allure-vitest

Version:
19 lines 762 B
import { AsyncLocalStorage } from "node:async_hooks"; import { getCurrentTest as getCurrentTestGlobal } from "@vitest/runner"; export const getAsyncContext = () => { const holder = globalThis; return (holder.__allureVitestAsyncContext ?? (holder.__allureVitestAsyncContext = { currentTaskStorage: new AsyncLocalStorage(), activeTasks: new WeakSet(), })); }; export const getCurrentTest = () => { const holder = globalThis; const asyncContext = holder.__allureVitestAsyncContext; const task = asyncContext?.currentTaskStorage.getStore(); if (task) { return (asyncContext?.activeTasks?.has(task) ?? true) ? task : undefined; } return getCurrentTestGlobal(); }; //# sourceMappingURL=concurrentState.js.map