fix: plugin script error halting JS execution (#1801)

This commit is contained in:
Marvin Hagemeister
2023-09-20 12:28:32 +02:00
committed by GitHub
parent 0c37b5f9b9
commit 3db514f869
8 changed files with 127 additions and 2 deletions
+31 -1
View File
@@ -1,3 +1,4 @@
import { assertMatch } from "$std/testing/asserts.ts";
import { ServerContext, Status } from "../server.ts";
import {
assert,
@@ -8,7 +9,12 @@ import {
} from "./deps.ts";
import manifest from "./fixture_plugin/fresh.gen.ts";
import options from "./fixture_plugin/options.ts";
import { runBuild, startFreshServer } from "./test_utils.ts";
import {
clickWhenListenerReady,
runBuild,
startFreshServer,
withPageName,
} from "./test_utils.ts";
const ctx = await ServerContext.fromManifest(manifest, options);
const handler = ctx.handler();
@@ -144,3 +150,27 @@ Deno.test("calls buildStart() and buildEnd()", async () => {
"Plugin b: buildEnd",
]);
});
Deno.test("plugin script doesn't halt island execution", async () => {
await withPageName(
"./tests/fixture_plugin_error/main.ts",
async (page, address) => {
let error;
page.on("pageerror", (err) => {
error = err;
});
await page.goto(address);
await page.waitForSelector("#ready");
let text = await page.$eval("p", (el) => el.textContent!);
assertEquals(text, "0");
await clickWhenListenerReady(page, "button");
text = await page.$eval("p", (el) => el.textContent!);
assertEquals(text, "1");
assertMatch(String(error), /Error thrown/);
},
);
});