Files
reverse-engineering-anything/src/browser/PlaywrightExecutionBoundary.test.ts
T
morluto 735c10059c refactor(domain): split error taxonomy into thematic modules (#636)
Move each error family out of domain/errors.ts into its own module
(base, core, provider selection/adapter, browser observation,
artifact, evidence, unknown registry, hopper, configuration) and
relocate AnalysisErrorProjection to analysisErrorProjection.
Migrate all 162 importers to the owning modules and delete
errors.ts. No re-export shims; behavior is unchanged.
2026-10-06 05:57:38 +08:00

35 lines
1.1 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "vitest";
import { withPlaywrightExecutionBoundary } from "./PlaywrightExecutionBoundary.js";
import {
AnalysisCancelledError,
AnalysisTimeoutError,
} from "../domain/analysisErrorCore.js";
describe("withPlaywrightExecutionBoundary", () => {
afterEach(() => vi.useRealTimers());
it("rejects work that exceeds its absolute remaining duration", async () => {
vi.useFakeTimers();
const result = withPlaywrightExecutionBoundary(
() => new Promise<never>(() => undefined),
25,
);
const rejection =
expect(result).rejects.toBeInstanceOf(AnalysisTimeoutError);
await vi.advanceTimersByTimeAsync(25);
await rejection;
});
it("rejects when the caller cancels active work", async () => {
const controller = new AbortController();
const result = withPlaywrightExecutionBoundary(
() => new Promise<never>(() => undefined),
1_000,
controller.signal,
);
controller.abort();
await expect(result).rejects.toBeInstanceOf(AnalysisCancelledError);
});
});