UNPKG

@arizeai/phoenix-client

Version:
38 lines 1.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.runStorage = void 0; exports.pushSuite = pushSuite; exports.popSuite = popSuite; exports.currentSuite = currentSuite; exports.currentRun = currentRun; const node_async_hooks_1 = require("node:async_hooks"); /** * AsyncLocalStorage that lets `logOutput` / `logAnnotation` / `evaluate` * reach the running test's state without threading it through arguments. */ exports.runStorage = new node_async_hooks_1.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. */ function pushSuite(suite) { suiteStack.push(suite); } /** Pop the current suite as we leave its `describe` callback. */ function popSuite() { return suiteStack.pop(); } /** The suite currently being declared, or `undefined` outside any `describe`. */ 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}. */ function currentRun() { return exports.runStorage.getStore(); } //# sourceMappingURL=state.js.map