Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI --coverage.exclude filter throws TypeError #3450

Closed
6 tasks done
iliketomatoes opened this issue May 25, 2023 · 3 comments · Fixed by #3506
Closed
6 tasks done

CLI --coverage.exclude filter throws TypeError #3450

iliketomatoes opened this issue May 25, 2023 · 3 comments · Fixed by #3506
Labels

Comments

@iliketomatoes
Copy link

Describe the bug

I'm using Vitest in a monorepository (with vitest.workspace.ts), and it looks like the only way to provide coverage options is through CLI.

The command I use includes this filter: --coverage.exclude='**/node_modules/**', which causes Vitest to throw this error:

TypeError: resolved.coverage.exclude.push is not a function

Reproduction

In a monorepository that leverages Vitest Workspaces, run this command:

npx vitest run --coverage.enabled --coverage.lines=50 --coverage.functions=50 --coverage.branches=50 --coverage.statements=50 --coverage.all --coverage.include='packages/**' --coverage.include='apps/**' --coverage.exclude='**/node_modules/**'

System Info

System:
    OS: macOS 12.6.3
    CPU: (10) arm64 Apple M1 Max
    Memory: 2.26 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.18.1 - ~/.nvm/versions/node/v16.18.1/bin/node
    Yarn: 3.2.3 - ~/.nvm/versions/node/v14.20.0/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v16.18.1/bin/npm
  Browsers:
    Brave Browser: 109.1.47.171
    Chrome: 113.0.5672.126
    Firefox: 113.0.2
    Safari: 16.3
  npmPackages:
    @vitest/coverage-c8: ^0.31.1 => 0.31.1 
    @vitest/ui: ^0.31.1 => 0.31.1 
    vitest: ^0.31.1 => 0.31.1

Used Package Manager

yarn

Validations

@sheremet-va
Copy link
Member

You can provide coverage options inside a vitest.config.ts

@iliketomatoes
Copy link
Author

You can provide coverage options inside a vitest.config.ts

I thought I was supposed to use defineProject (which doesn't support the coverage property) even at the root level. Thanks!

@sheremet-va
Copy link
Member

We should probably guard all possible properties with toArray method.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants