Skip to content

Commit 85b38df

Browse files
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>
1 parent 24c86ea commit 85b38df

1 file changed

Lines changed: 38 additions & 2 deletions

File tree

src/dev/builder_test.ts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { expect } from "@std/expect";
1+
import { expect, fn } from "@std/expect";
22
import * as path from "@std/path";
33
import { Builder, specToName } from "./builder.ts";
44
import { App } from "../app.ts";
5+
import { DEV_ERROR_OVERLAY_URL } from "../constants.ts";
56
import { BUILD_ID } from "../runtime/build_id.ts";
67
import { withTmpDir, writeFiles } from "../test_utils.ts";
78
import { withChildProcessServer } from "../../tests/test_utils.tsx";
@@ -381,8 +382,43 @@ Deno.test({
381382
controller.abort();
382383
},
383384
});
385+
},
386+
sanitizeOps: false,
387+
sanitizeResources: false,
388+
});
389+
390+
Deno.test({
391+
name: "Builder - dev server error_overlay ignores _app and _layout",
392+
fn: async () => {
393+
const root = path.join(import.meta.dirname!, "..", "..");
394+
await using _tmp = await withTmpDir({ dir: root, prefix: "tmp_builder_" });
395+
const tmp = _tmp.dir;
396+
const appLayoutSpy = fn(() => "app or layout") as () => string;
384397

385-
// expect(text).toContain("<h1>ok</h1>");
398+
const app = new App()
399+
.appWrapper(appLayoutSpy)
400+
.layout("/", appLayoutSpy);
401+
402+
const builder = new Builder({
403+
root: tmp,
404+
outDir: path.join(tmp, "dist"),
405+
});
406+
407+
const controller = new AbortController();
408+
await builder.listen(() => Promise.resolve<App<unknown>>(app), {
409+
signal: controller.signal,
410+
async onListen(addr) {
411+
const res = await fetch(
412+
`http://localhost:${addr.port}/${DEV_ERROR_OVERLAY_URL}?message=__ok__`,
413+
);
414+
415+
const text = await res.text();
416+
expect(text).toMatch(/__ok__/);
417+
expect(appLayoutSpy).toHaveBeenCalledTimes(0);
418+
419+
controller.abort();
420+
},
421+
});
386422
},
387423
sanitizeOps: false,
388424
sanitizeResources: false,

0 commit comments

Comments
 (0)