Skip to content

tests: use the same browser instance across tests and better use explicit resource management#2901

Merged
marvinhagemeister merged 10 commits intodenoland:mainfrom
iuioiua:browser-instance
May 21, 2025
Merged

tests: use the same browser instance across tests and better use explicit resource management#2901
marvinhagemeister merged 10 commits intodenoland:mainfrom
iuioiua:browser-instance

Conversation

@iuioiua
Copy link
Contributor

@iuioiua iuioiua commented May 7, 2025

On my machine, reduces time taken to perform deno task test from ~1m20s to ~30s.

Inspired by and supersedes #2110.

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.

Comment on lines +39 to +46
const browser = await launch({
args: ["--window-size=1280,720"],
headless: true,
});

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

Choose a reason for hiding this comment

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

@lino-levan, when I use await using, tests hang.

- name: Type check project
run: deno task check:types

- name: Disable AppArmor
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is worth trying.

@iuioiua iuioiua changed the title test: use the same browser instance across tests test: use the same browser instance across tests and better use explicit resource management May 8, 2025
@iuioiua iuioiua marked this pull request as ready for review May 8, 2025 00:36
@iuioiua iuioiua changed the title test: use the same browser instance across tests and better use explicit resource management tests: use the same browser instance across tests and better use explicit resource management May 12, 2025
@iuioiua
Copy link
Contributor Author

iuioiua commented May 12, 2025

PTAL @marvinhagemeister

@iuioiua iuioiua requested a review from marvinhagemeister May 12, 2025 23:08
@iuioiua
Copy link
Contributor Author

iuioiua commented May 18, 2025

@marvinhagemeister, are you able to please take a look? It'd be great to have this bump in test performance.

Copy link
Collaborator

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

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

LGTM

@marvinhagemeister marvinhagemeister merged commit da8879d into denoland:main May 21, 2025
7 checks passed
@iuioiua iuioiua deleted the browser-instance branch May 21, 2025 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants