fix: show original error page in dev (#2074)
This commit is contained in:
+13
-22
@@ -1,25 +1,16 @@
|
||||
import { ServerContext, Status } from "../server.ts";
|
||||
import { assert, assertEquals, assertStringIncludes } from "./deps.ts";
|
||||
import manifest from "./fixture_error/fresh.gen.ts";
|
||||
|
||||
const ctx = await ServerContext.fromManifest(manifest, { dev: true });
|
||||
const handler = ctx.handler();
|
||||
const router = (req: Request) => {
|
||||
return handler(req, {
|
||||
remoteAddr: {
|
||||
transport: "tcp",
|
||||
hostname: "127.0.0.1",
|
||||
port: 80,
|
||||
},
|
||||
});
|
||||
};
|
||||
import { Status } from "../server.ts";
|
||||
import { assertEquals, assertStringIncludes } from "./deps.ts";
|
||||
import { getErrorOverlay, withFakeServe } from "./test_utils.ts";
|
||||
|
||||
Deno.test("error page rendered", async () => {
|
||||
const resp = await router(new Request("https://fresh.deno.dev/"));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, Status.InternalServerError);
|
||||
assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8");
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, `Error: boom!`);
|
||||
assertStringIncludes(body, `at render`);
|
||||
await withFakeServe("./tests/fixture_error/dev.ts", async (server) => {
|
||||
const resp = await server.get("/");
|
||||
assertEquals(resp.status, Status.InternalServerError);
|
||||
assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8");
|
||||
await resp.text(); // Consume
|
||||
|
||||
const { title, stack } = await getErrorOverlay(server, "/");
|
||||
assertStringIncludes(title, `boom!`);
|
||||
assertStringIncludes(stack, `at render`);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user