fix: plugin script error halting JS execution (#1801)
This commit is contained in:
+31
-1
@@ -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/);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user