/** * @fileoverview Test-only helpers for running test bodies inside a * `RunScope` with explicit registry/cache wiring. * * Production code reads registries via `currentScope()`. After the T1 * deferred-task wave deleted `defaultLanguageRegistry` and * `defaultToolRegistry`, tests that touched registry-aware code paths * (canonicalize, forFile, plugin loader, parse-cache) had to construct * a scope per test. These helpers centralise that boilerplate so the * churn per migrated test file is one import + one wrap. * * Usage: * * import { withScope, makeTestScope } from '@opensip-tools/core/test-utils/with-scope.js'; * * it('does the thing', async () => { * const scope = makeTestScope(); * scope.languages.register(myAdapter); * await withScope(scope, async () => { * expect(myFunctionThatReadsScope()).toBe('expected'); * }); * }); * * `withScope` is a thin alias for `runWithScope` that returns the * function's return value; `makeTestScope` is a default-arg constructor * for a scope with fresh empty registries. */ import { RunScope } from '../lib/run-scope.js'; import type { RunScopeOptions } from '../lib/run-scope.js'; /** * Construct a fresh `RunScope` with empty `LanguageRegistry` / * `ToolRegistry` instances. Override any field via `opts`. */ export declare function makeTestScope(opts?: RunScopeOptions): RunScope; /** Run `fn` inside `scope` and return its result. Thin alias for `runWithScope`. */ export declare function withScope(scope: RunScope, fn: () => Promise): Promise; /** Synchronous variant of `withScope`. */ export declare function withScopeSync(scope: RunScope, fn: () => T): T; //# sourceMappingURL=with-scope.d.ts.map