fix: Use custom 500 page for *all* handlers if present (#1362)

This commit is contained in:
Kamil Ogórek
2023-06-27 11:05:05 +02:00
committed by GitHub
parent ee3e4a1145
commit aff31c0f15
8 changed files with 108 additions and 1 deletions
+37
View File
@@ -782,3 +782,40 @@ Deno.test("PORT environment variable", {
await lines.cancel();
serverProcess.kill("SIGTERM");
});
Deno.test("rendering custom _500.tsx page for default handlers", {
sanitizeOps: false,
sanitizeResources: false,
}, async (t) => {
// Preparation
const { serverProcess, lines, address } = await startFreshServer({
args: ["run", "-A", "./tests/fixture_custom_500/main.ts"],
});
await delay(100);
await t.step("SSR error is shown", async () => {
const resp = await fetch(address);
assertEquals(resp.status, Status.InternalServerError);
const text = await resp.text();
assertStringIncludes(text, "Custom 500: Pickle Rick!");
});
const browser = await puppeteer.launch({ args: ["--no-sandbox"] });
const page = await browser.newPage();
await page.goto(address, {
waitUntil: "networkidle2",
});
await t.step("error page is shown with error message", async () => {
const el = await page.waitForSelector(".custom-500");
const text = await page.evaluate((el) => el.textContent, el);
assertStringIncludes(text, "Custom 500: Pickle Rick!");
});
await browser.close();
await lines.cancel();
serverProcess.kill("SIGTERM");
});