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 <marvin@deno.com>
This commit is contained in:
Christian Svensson
2025-08-01 12:53:06 +02:00
committed by GitHub
co-authored by Marvin Hagemeister
parent 24c86ea20e
commit 85b38df578
+38 -2
View File
@@ -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("<h1>ok</h1>");
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<unknown>>(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,