vitest icon indicating copy to clipboard operation
vitest copied to clipboard

Workspace configuration works only with inline configuration

Open ascariandrea opened this issue 2 years ago • 6 comments

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

ascariandrea avatar Nov 23 '23 08:11 ascariandrea

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

sheremet-va avatar Nov 23 '23 08:11 sheremet-va

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

ascariandrea avatar Nov 23 '23 09:11 ascariandrea

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

sheremet-va avatar Nov 23 '23 10:11 sheremet-va

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.

Lewenhaupt avatar Nov 30 '23 10:11 Lewenhaupt

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.

sheremet-va avatar Dec 04 '23 13:12 sheremet-va

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

ascariandrea avatar Dec 05 '23 09:12 ascariandrea