Skip to content

exclude filter should not consider absolute path #3802

@g-plane

Description

@g-plane

Describe the bug

In our private CI system, all projects will be put into $HOME/.cache/projects when cloning repositories. However, Vitest's default exclude filter will ignore all the files whose paths contains .cache . This sounds OK when there're some directories called .cache in current working directory. But for us, $HOME/.cache isn't not a directory under current working directory.

When researching the logic of Vitest, I found that the absolute option of fast-glob was set to true, so all the test files (e.g. $HOME/.cache/projects/example.test.ts) will match that exclude filter, which causes Vitest exits with No test files found error.

Here is the absolute option:

I know we can change our Vitest config to let Vitest not ignore the paths contain .cache, but I'm still curious why the absolute option was enabled. In my opinion, both include and exclude options should only be considered under current working directory with relative path, not absolute path.

Reproduction

This issue can't be simulated with online sandbox or a reproduction repo, but this issue can be reproduced by moving a project to a directory called .cache. You can simply create a directory called .cache and move into it.

System Info

System: Linux
Vitest version: v0.33.0

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions