Skip to content

Allow to exclude test files with cli #4148

@jonatan-zint-tfs

Description

@jonatan-zint-tfs

Clear and concise description of the problem

I have the following use case for an exclude flag in the vitest cli:

We have a codebase with some unit tests using vitest in ./src/
Alongside this code base there are some integration tests sharing the dto interfaces from ./src/. The integration tests are in ./tests/api/ and use their own vitest config in ./tests/api/vitest.config.ts.

We use lint-staged to execute relevant tests with vite related like the docs suggest.

However - those integration tests should not run in our commit hook due to their fragile nature. So I'd like to pass an exclude flag like so vitest related --exclude './tests/api/**'.

I couldn't find a solution with the already available CLI options. -t will only work on test names, but I want to exlude files.

Suggested solution

Introduce an --exclude that'll exclude all tests matching a regex pattern in this CLI run. It'll override any exclude/include pattern from the vitest config files.

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions