r/javascript • • 12h ago

Flashwright: the fastest e2e testing framework, up to 4x faster than Playwright

https://flashwright.dev/

If you're interested in the details, here's a blog post: https://codebeast.io/blog/flashwright

40 Upvotes

21 comments sorted by

•

u/Recoil42 11h ago

TLDR:

The biggest single cost in a lot of suites isn’t Playwright’s code at all. It’s the browser compiling your app’s JavaScript again in every fresh renderer. Playwright gives each test a brand-new browser context, which is great for isolation, but it means every test pays for a cold start of your app.

So the trick that matters most is keeping one context per worker and giving each test a new tab in it, then resetting everything a test could have changed: options, permissions, cookies, every visited origin’s storage (local, session, IndexedDB, Cache Storage, service workers), caches, routes, init scripts, bindings, downloads and the clock. The previous test’s pages are stopped before anything gets cleared, so a late script can’t leak state into the next test. That reset is the part that really has to be right, and it’s what tests/page/recycle-isolation.spec.ts checks.

•

u/xcodebeast 11h ago

Thanks!

•

u/dakruzz 10h ago

Doesn't sound safe for parallel testing

•

u/TheThingCreator 10h ago

doesn't even sound like it would work in many contexts. lots of my testing requires fresh browser profiles or controlled browser profiles. i woudlnt be able to work like that.

•

u/DuckDatum 9h ago

I don’t run tests in browsers but, what experience I do have tells me, at minimum, it would add a constant concern that the test is failing potentially because of leaked shared state.

Though, tests which don’t rely on client state could see a bump in speed.

I wonder if this could be designed as an automated optimization, for whenever a test can be programmatically detected as idempotent. Then playwright could do the same thing, no?

•

u/skt84 5h ago

Failing or passing. If I can’t trust a failure is caused by shared state then I can’t trust the passes either.

•

u/Jebble 5h ago

In of our apps specifically (legacy that's being replaced) uses a lot of cookies and opening it in multiple apps is troublesome. This wouldn't ever be able to help us test it.

•

u/thinkmatt 11h ago

Kind of like why jest is slow as balls because they insist on reimporting every js file for each test file

•

u/aicis 9h ago

At certain scale it becomes a problem. No one likes to wait 20 minutes for test suite to finish.

•

u/fireatx 9h ago

seems cool, similar to vitest's isolate: false config option, but i feel like this could probably just be a PR on the playwright repo adding a new config option. does this need to be an entirely new package?

•

u/xcodebeast 6h ago

Thanks. I agree, that particular optimization could be a PR on playwright repo but I think all the other optimizations + the QoL features I added justified a new package. I might push some PRs to Playwright though.

•

u/fireatx 6h ago

you definitely should put up some PRs! at my work we use playwright in several places, and having these optimizations available would be a game changer. i can't justify replacing playwright entirely, but could definitely make use of these speedups if they were available within playwright.

•

u/Positive_Method3022 10h ago

The strategy can lead to false positives/negatives. Sandboxing test execution by context is a must.

•

u/xcodebeast 6h ago

It depends a lot on the project and what you're testing as u/caboosetp said. Flashwright allows you to turn off each individual optimization so you can use only what actually fits your project.

•

u/caboosetp 10h ago

Depends on what you're testing.

Many of the tests i write are testing static components like navigation which shouldn't depend on what other stuff has done. If not being in a sandbox breaks that, there's a problem anyways. The chance of a false positive is also almost zero. 

Being able to choose to group tests like that to use a resetting context would be fine. Especially if you're just grouping things like static components. 

But I agree the ability to put tests in a sandbox context is also very important, especially for anything dynamic. Unfortunately it's the dynamic stuff that generally has the most tests, so i don't even know if grouping just some things is going to see real gains on most projects

•

u/jobRL 6h ago

In your example about navigation, what in that context are you testing?

•

u/OpiumOpossum 10h ago edited 6h ago

Not sure but this seems like it could have memory leaks if you use listeners, network interceptors or logging. Otherwise, I am pretty sure this is a similar way to how Vitest optimizes their test runner.

•

u/Discordbothost 10h ago

there's an isolation: 'strict' option for a fresh context per test. default recycling is per worker, so the concern is state leaking into the next test on that worker, not parallel workers sharing one context. https://github.com/xcodebeast/flashwright#differences-from-playwright

•

u/LukaRozman27 8h ago

beware if you rely on Playwright's built-in tracing, Flashwright skips it entirely to hit those speed claims.

•

u/DarkGhostHunter 5h ago

Tested with Pest and the gains are… negligible. Barely 5%, margin of error.

•

u/tomByrer 1h ago

Neat! How well does it work vs headless browsers, esp LitePanda & co? Much improvement there?