vitest-dev / vitest

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

Workspace configuration works only with inline configuration #4577

Open ascariandrea opened 11 months ago

ascariandrea commented 11 months ago

Describe the bug

Hi there, I'm having an issue with workspace configuration in my project. Basically, it runs all the tests only when configurations are defined inline, while it runs only the first matched when defined with the glob pattern.

In the reproduction I've defined the vitest.workspace.ts with both configurations (the glob pattern one is commented) so you can check this properly.

Reproduction

https://stackblitz.com/edit/stackblitz-starters-qrhqud?file=vitest.workspace.ts

System Info

System:
    OS: Linux 6.2 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
    Memory: 4.10 GB / 15.34 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 16.20.0 - ~/.nvm/versions/node/v16.20.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.20.0/bin/yarn
    npm: 9.7.1 - ~/.nvm/versions/node/v16.20.0/bin/npm
    bun: 1.0.3 - ~/.bun/bin/bun
  Browsers:
    Chrome: 119.0.6045.159
  npmPackages:
    @vitest/coverage-v8: ^0.34.5 => 0.34.6 
    @vitest/ui: ^0.34.6 => 0.34.6 
    vitest: ^0.34.5 => 0.34.6

Used Package Manager

yarn

Validations

sheremet-va commented 11 months ago

Vitest uses only a single config per folder at the moment, it filters others out.

ascariandrea commented 11 months ago

Thanks for the quick reply @sheremet-va, did I miss this point in the documentation or is not highlighted at all?

sheremet-va commented 11 months ago

It's not highlighted, and looks like a bug to be honest.

Lewenhaupt commented 10 months ago

Also encountered this when I tried to add a config file for unit tests and one for integration tests in the same folder. But simple enough to move to a subfolder for my integration tests as a workaround.

sheremet-va commented 10 months ago

I think the initial idea was to filter out vite.config if there is a vitest.config in the same folder. Instead of the current solution, we should just remove vite.config if there is already a vitest.config in the folder.

ascariandrea commented 10 months ago

@sheremet-va yes, the correct implementation I expect would filter out the vite(st).config keeping all the others matching the glob pattern.