UNPKG

@arizeai/phoenix-client

Version:
57 lines 2.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.it = exports.test = exports.describe = exports.traceEvaluator = exports.logOutput = exports.logAnnotation = exports.evaluate = void 0; const define_api_1 = require("../testing/define-api"); var helpers_1 = require("../testing/helpers"); Object.defineProperty(exports, "evaluate", { enumerable: true, get: function () { return helpers_1.evaluate; } }); Object.defineProperty(exports, "logAnnotation", { enumerable: true, get: function () { return helpers_1.logAnnotation; } }); Object.defineProperty(exports, "logOutput", { enumerable: true, get: function () { return helpers_1.logOutput; } }); Object.defineProperty(exports, "traceEvaluator", { enumerable: true, get: function () { return helpers_1.traceEvaluator; } }); /** * Resolve jest globals lazily. Jest injects `describe`, `test`, `it`, * `beforeAll`, `afterAll` onto the global object during test runs; we read * them off `globalThis` so importing this module outside of a jest run * doesn't error. */ function getJestGlobals() { var _a; const g = globalThis; if (!g.describe || !g.beforeAll || !g.afterAll) { throw new Error("@arizeai/phoenix-client/jest could not find Jest globals. Make sure this module " + "is imported from inside a Jest test file."); } const test = (_a = g.test) !== null && _a !== void 0 ? _a : g.it; if (!test) { throw new Error("@arizeai/phoenix-client/jest could not find Jest's test/it."); } return { describe: g.describe, test, beforeAll: g.beforeAll, afterAll: g.afterAll, }; } /** * Build the runner hooks from the (lazily-resolved) jest globals. Memoized so * repeated declarations don't re-read `globalThis` on every call; jest injects * its globals once per worker before any test file is evaluated. */ let cachedHooks; function getHooks() { if (cachedHooks) return cachedHooks; const g = getJestGlobals(); cachedHooks = { describe: (name, fn) => g.describe(name, fn), describeOnly: (name, fn) => g.describe.only(name, fn), describeSkip: (name, fn) => g.describe.skip(name, fn), test: (name, fn, timeout) => g.test(name, fn, timeout), testOnly: (name, fn, timeout) => g.test.only(name, fn, timeout), testSkip: (name, fn, timeout) => g.test.skip(name, fn, timeout), beforeAll: (fn) => g.beforeAll(fn), afterAll: (fn) => g.afterAll(fn), }; return cachedHooks; } ({ describe: exports.describe, test: exports.test, it: exports.it } = (0, define_api_1.createTestApi)(getHooks)); //# sourceMappingURL=index.js.map