@arizeai/phoenix-client
Version:
A client for the Phoenix API
31 lines • 1.1 kB
JavaScript
import { AsyncLocalStorage } from "node:async_hooks";
/**
* AsyncLocalStorage that lets `logOutput` / `logAnnotation` / `evaluate`
* reach the running test's state without threading it through arguments.
*/
export const runStorage = new AsyncLocalStorage();
/**
* Stack of currently active suites. Tests declared inside a `describe`
* callback consult the top of this stack to register themselves.
*/
const suiteStack = [];
/** Push a suite onto the stack as we enter its `describe` callback. */
export function pushSuite(suite) {
suiteStack.push(suite);
}
/** Pop the current suite as we leave its `describe` callback. */
export function popSuite() {
return suiteStack.pop();
}
/** The suite currently being declared, or `undefined` outside any `describe`. */
export function currentSuite() {
return suiteStack[suiteStack.length - 1];
}
/**
* The state for the test currently executing, or `undefined` when called
* outside a Phoenix test body. Backed by {@link runStorage}.
*/
export function currentRun() {
return runStorage.getStore();
}
//# sourceMappingURL=state.js.map