[Feature Request] Keep browser loaded between tests
Describe the Feature request
Currently, it seems that a new browser window is being opened for each test. Unfortunately, that causes a long loading time in development for vite projects, which do not bundle modules in development, which can result in thousands of requests at page load (with the promised payback of faster hot module reload times). Currently, I'm seeing load times of 20-30 seconds per test. Production is much faster, because vite does bundle production builds.
Ideally, it would be great if a single browser window could remain open, and navigation to different stories could happen via history.replaceState or something, rather than full new page loads. I'm not sure how feasible that is, honestly, but it could help speed things up, maybe.
Additional context
FWIW, web-test-runner uses websockets in its interactions with playwright, which means it only needs to open the browser once, and each test is injected via ws. Not sure if that would work here, but it's an idea.
AFAIK the maxWorkers determines how many pages get created. these pages get reused throughout the lifetime of the test run, unless there is a failing test. at that point, the page gets reset. How many workers are you using?
Github runners have two cores, so two I guess two workers.
these pages get reused throughout the lifetime of the test run
Are you sure about that? I see output like this, which makes me think that each story needs to load a new page
page loaded in 782ms.
PASS browser: chromium src/components/patterns/snippet/Snippet.stories.tsx
page loaded in 798ms.
PASS browser: chromium src/components/atoms/forms/textarea/Textarea.stories.tsx
page loaded in 788ms.
PASS browser: chromium src/components/atoms/buttons/inline-button/InlineButton.stories.tsx
page loaded in 787ms.
PASS browser: chromium src/components/patterns/page-header/PageHeader.stories.tsx
page loaded in 768ms.
PASS browser: chromium src/components/atoms/forms/label/Label.stories.tsx
Hmm can confirm that it opens a new browser for each story file. @yannbf this sounds like a bug to me. WDYT?
I think this might just be the way that the jest runner for playwright works. I believe a new page is loaded each time using https://playwright.dev/docs/api/class-page#page-goto. I've opened https://github.com/playwright-community/jest-playwright/issues/791 asking if perhaps there's a way to avoid that full page load each time.