fix: only load error overlay in development (#2460)

This commit is contained in:
Marvin Hagemeister
2024-05-24 20:29:59 +02:00
committed by GitHub
parent 584e5716c3
commit 77dc77826e
2 changed files with 21 additions and 1 deletions
@@ -55,3 +55,23 @@ Deno.test("error overlay - should not be visible for HttpError <500", async () =
expect(content).toContain("fresh-error-overlay");
expect(res.status).toEqual(500);
});
Deno.test("error overlay - should not be visible in prod", async () => {
const app = new App();
app.use(devErrorOverlay());
app.config.mode = "production";
app.get("/", () => {
throw new HttpError(500);
});
const server = new FakeServer(await app.handler());
const res = await server.get("/", {
headers: {
accept: "text/html",
},
});
const content = await res.text();
expect(content).not.toContain("fresh-error-overlay");
expect(res.status).toEqual(500);
});
+1 -1
View File
@@ -488,7 +488,7 @@ function FreshRuntimeScript() {
__html: scriptContent,
}}
/>
<ShowErrorOverlay />
{ctx.config.mode === "development" ? <ShowErrorOverlay /> : null}
</>
);
}