Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 14 additions & 21 deletions tests/test_utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ import { NodeProcess } from "./fixtures_islands/NodeProcess.tsx";
import { FreshAttrs } from "./fixtures_islands/FreshAttrs.tsx";
import { OptOutPartialLink } from "./fixtures_islands/OptOutPartialLink.tsx";

const browser = await launch({
args: [
"--window-size=1280,7201",
...((Deno.env.get("CI") && Deno.build.os === "linux")
? ["--no-sandbox"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the advantage? Genuine question.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or do you think that's the issue here?

Copy link
Contributor

@lino-levan lino-levan May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The biggest reason is it cleans up the codebase. I've heard of really obscure bugs not being caught in CI because of --no-sandbox, but I've never seen one myself so take that with a grain of salt.

: []),
],
headless: true,
});

addEventListener("unload", async () => {
await browser.close();
});

export function getIsland(pathname: string) {
return path.join(
import.meta.dirname!,
Expand Down Expand Up @@ -85,37 +99,17 @@ export async function withBrowserApp(
signal: aborter.signal,
}, await app.handler());

const browser = await launch({
args: [
"--window-size=1280,720",
...((Deno.env.get("CI") && Deno.build.os === "linux")
? ["--no-sandbox"]
: []),
],
headless: true,
});

const page = await browser.newPage();
try {
await fn(page, `http://localhost:${server.addr.port}`);
} finally {
await page.close();
await browser.close();
aborter.abort();
await server?.finished;
}
}

export async function withBrowser(fn: (page: Page) => void | Promise<void>) {
const browser = await launch({
args: [
"--window-size=1280,7201",
...((Deno.env.get("CI") && Deno.build.os === "linux")
? ["--no-sandbox"]
: []),
],
headless: true,
});
const page = await browser.newPage();
try {
await fn(page);
Expand All @@ -128,7 +122,6 @@ export async function withBrowser(fn: (page: Page) => void | Promise<void>) {
throw err;
} finally {
await page.close();
await browser.close();
}
}

Expand Down
Loading