diff --git a/tests/boundary/filesystem/javascript-applications/javascriptApplicationService.test.ts b/tests/boundary/filesystem/javascript-applications/javascriptApplicationService.test.ts index 05cf749ca83..b52ada3b424 100644 --- a/tests/boundary/filesystem/javascript-applications/javascriptApplicationService.test.ts +++ b/tests/boundary/filesystem/javascript-applications/javascriptApplicationService.test.ts @@ -373,6 +373,21 @@ describe("Selected JavaScript source failure diagnostics", () => { }); }); +const analyzeWithTerminalProgressFailure = ( + inputPath: string, + cause: unknown, +) => + analyzeJavaScriptApplication( + { input_path: inputPath, format: "directory" }, + { + progress: { + report: async (event) => { + if (event.terminal) throw cause; + }, + }, + }, + ); + describe("JavaScript application failure diagnostics", () => { it("identifies the rejected result field in caller-visible diagnostics", async () => { const inputPath = await createTestTempDirectory("rea-js-schema-failure-"); @@ -384,16 +399,7 @@ describe("JavaScript application failure diagnostics", () => { message: "Semantic node references an absent application node", }, ]); - const result = await analyzeJavaScriptApplication( - { input_path: inputPath, format: "directory" }, - { - progress: { - report: async (event) => { - if (event.terminal) throw cause; - }, - }, - }, - ); + const result = await analyzeWithTerminalProgressFailure(inputPath, cause); if (result.ok) throw new Error("Expected analysis failure"); expect(result.error.cause).toBe(cause); @@ -414,16 +420,7 @@ describe("JavaScript application failure diagnostics", () => { const cause = new RangeError("Invalid string length"); // Retain the original failure locally, but never serialize its object graph. cause.cause = cause; - const result = await analyzeJavaScriptApplication( - { input_path: inputPath, format: "directory" }, - { - progress: { - report: async (event) => { - if (event.terminal) throw cause; - }, - }, - }, - ); + const result = await analyzeWithTerminalProgressFailure(inputPath, cause); if (result.ok) throw new Error("Expected analysis failure"); expect(result.error.cause).toBe(cause); expect(projectAnalysisError(result.error)).toMatchObject({ @@ -463,16 +460,7 @@ describe("JavaScript application failure diagnostics", () => { async (cause) => { const inputPath = await createTestTempDirectory("rea-js-non-error-"); await writeFile(join(inputPath, "main.js"), "export const value = 1;\n"); - const result = await analyzeJavaScriptApplication( - { input_path: inputPath, format: "directory" }, - { - progress: { - report: async (event) => { - if (event.terminal) throw cause; - }, - }, - }, - ); + const result = await analyzeWithTerminalProgressFailure(inputPath, cause); if (result.ok) throw new Error("Expected analysis failure"); expect(projectAnalysisError(result.error)).toMatchObject({ code: "execution_failure", @@ -495,16 +483,7 @@ describe("JavaScript application failure diagnostics", () => { const inputPath = await createTestTempDirectory("rea-js-oversized-"); await writeFile(join(inputPath, "main.js"), "export const value = 1;\n"); const message = cause instanceof Error ? cause.message : cause; - const result = await analyzeJavaScriptApplication( - { input_path: inputPath, format: "directory" }, - { - progress: { - report: async (event) => { - if (event.terminal) throw cause; - }, - }, - }, - ); + const result = await analyzeWithTerminalProgressFailure(inputPath, cause); if (result.ok) throw new Error("Expected analysis failure"); expect(projectAnalysisError(result.error)).toMatchObject({ code: "execution_failure",