feat: add nice error page during development (#122)
Co-authored-by: Luca Casonato <hello@lcas.dev>
This commit is contained in:
co-authored by
Luca Casonato
parent
837d2a7f5e
commit
026ed86f40
@@ -0,0 +1,20 @@
|
||||
import { ServerContext } from "../server.ts";
|
||||
import { assert, assertEquals, assertStringIncludes } from "./deps.ts";
|
||||
import manifest from "./fixture_error/fresh.gen.ts";
|
||||
|
||||
const ctx = await ServerContext.fromManifest(manifest);
|
||||
const router = ctx.handler();
|
||||
|
||||
Deno.test("error page rendered", async () => {
|
||||
const resp = await router(new Request("https://fresh.deno.dev/"));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, 500);
|
||||
assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8");
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(
|
||||
body,
|
||||
`An error occured during route handling or page rendering.`,
|
||||
);
|
||||
assertStringIncludes(body, `Error: boom!`);
|
||||
assertStringIncludes(body, `at render`);
|
||||
});
|
||||
Reference in New Issue
Block a user