From 85b38df57806a3a6b72236a1e102990ad0e29e7f Mon Sep 17 00:00:00 2001 From: Christian Svensson Date: Fri, 1 Aug 2025 12:53:06 +0200 Subject: [PATCH] test: check that _app and _layout are ignored by dev err frame (#3168) Encountered this issue in #3167, but already fixed in #3165. I noticed `/_frsh/error_overlay` was using `_app`/`_layout`, which seemed unnecessary. Since this was already fixed in #3165, I just added a test to check that this is not a regression in the future. --------- Co-authored-by: Marvin Hagemeister --- src/dev/builder_test.ts | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/dev/builder_test.ts b/src/dev/builder_test.ts index bb1784ff..c8645666 100644 --- a/src/dev/builder_test.ts +++ b/src/dev/builder_test.ts @@ -1,7 +1,8 @@ -import { expect } from "@std/expect"; +import { expect, fn } from "@std/expect"; import * as path from "@std/path"; import { Builder, specToName } from "./builder.ts"; import { App } from "../app.ts"; +import { DEV_ERROR_OVERLAY_URL } from "../constants.ts"; import { BUILD_ID } from "../runtime/build_id.ts"; import { withTmpDir, writeFiles } from "../test_utils.ts"; import { withChildProcessServer } from "../../tests/test_utils.tsx"; @@ -381,8 +382,43 @@ Deno.test({ controller.abort(); }, }); + }, + sanitizeOps: false, + sanitizeResources: false, +}); - // expect(text).toContain("

ok

"); +Deno.test({ + name: "Builder - dev server error_overlay ignores _app and _layout", + fn: async () => { + const root = path.join(import.meta.dirname!, "..", ".."); + await using _tmp = await withTmpDir({ dir: root, prefix: "tmp_builder_" }); + const tmp = _tmp.dir; + const appLayoutSpy = fn(() => "app or layout") as () => string; + + const app = new App() + .appWrapper(appLayoutSpy) + .layout("/", appLayoutSpy); + + const builder = new Builder({ + root: tmp, + outDir: path.join(tmp, "dist"), + }); + + const controller = new AbortController(); + await builder.listen(() => Promise.resolve>(app), { + signal: controller.signal, + async onListen(addr) { + const res = await fetch( + `http://localhost:${addr.port}/${DEV_ERROR_OVERLAY_URL}?message=__ok__`, + ); + + const text = await res.text(); + expect(text).toMatch(/__ok__/); + expect(appLayoutSpy).toHaveBeenCalledTimes(0); + + controller.abort(); + }, + }); }, sanitizeOps: false, sanitizeResources: false,