vitest-dev / vitest

Next generation testing framework powered by Vite.
https://vitest.dev
MIT License
13.03k stars 1.17k forks source link

Browser tests don't run in parallel with `browser.enabled = true` #6834

Open timganter opened 4 days ago

timganter commented 4 days ago

Describe the bug

When running a single test file using playwright in webkit, chromium, and firefox in a workspace, they run sequentially instead of in parallel.

Reproduction

Steps to reproduce

  1. Download this stackblitz: https://stackblitz.com/edit/vitest-dev-vitest-ezbb8s
  2. npm install (locally)
  3. npm test (locally)

You should see that the browser tests run locally. Confirmed by @hi-ogawa over Discord who suggested making an issue.

Video of repro

https://github.com/user-attachments/assets/c113285a-a8d6-470e-9f9c-28091ee74e03

System Info

MacBook Pro with `Total Number of Cores: 12 (8 performance and 4 efficiency)`

Used Package Manager

npm

Validations

hi-ogawa commented 4 days ago

I just found there's TODO for this.

https://github.com/vitest-dev/vitest/blob/5e6de2742f329b7e65fe3dff4827b5134d777009/packages/browser/src/node/pool.ts#L125-L132

Probably you can patch this to Promise.all and see how it goes. I think the concern is that running multiple browsers can be heavy especially on CI with less resource.

    await Promise.all(groupedFiles.entries().map(async ([project, files]) => {
      await executeTests(method, project, files)
    }))