vitest: Regression: v2.1.0 makes folder globbing impossible in `vitest.workspace.ts` (No loader is configured for ".gitignore" files: .gitignore)

Describe the bug

I am aware that v2.1.0 made backwards incompatible changes, and that this was intentional.

It appears to be impossible (since v2.1.0) to glob for folders instead of files in vitest.workspace.ts.

The documentation states that this is valid configuration:

export default [
  'packages/*'
]

This appears to be incorrect, as it will now match any files in packages/ as a config file (i.e. packages/.gitignore, etc.)

I believe that this should be updated to read:

export default [
  'packages/*/'
]

Unfortunately this also does not work; it is additionally matching other files within the sub-folder as configuration files. (i.e.packages/package-1/.gitignore)

Reproduction

Previously (before v2.1.0), my vitest.workspace.ts contained:

export default ["./*"];

So all direct sub-folders (one level down) were considered packages in the workspace.

Today (when upgrading to ^2.1.0)

This works:

export default ["*/*vitest*"];

But the following all break (with some variant of No loader is configured for ".gitignore" files: .gitignore):

  • original, broken as expected by v2.1.0
    export default ["./*"];
    
  • Same but ending with /. I think we should expect this to only match folders, not files in those folders?
    export default ["./*/"];
    
  • Excluding ./ but ending with /. I think we should expect this to only match folders, not files in those folders?
    export default ["*/"];
    

System Info

`vitest ^2.1.0`

Tested with vitest `2.1.1`.

Used Package Manager

pnpm

Validations

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 24 (15 by maintainers)

Most upvoted comments

Arguably, **/*.js/ should never match /hello/world.js, since there is no sequence of characters that you can replace the *'s with to make these identical.

**/ would be the exception that proves the rule, in that ** specifically means “match the following at any number of directories down, including the current one”, so ./**/foo must match ./foo. I suspect what we’re seeing here is a bug related to this^ exception.

just opened mrmlnc/fast-glob#458

how does fs.glob handle patterns without trailing slashes that refer to directories (i.e. a "src" pattern)? all i know is that fast-glob matches directories without needing a trailing slash on the pattern

Like you would expect:

> require('fs').globSync('./patches')
[ 'patches' ]
> require('fs').globSync('./patches/')
[ 'patches' ]
> require('fs').globSync('patches')
[ 'patches' ]

all i know is that fast-glob matches directories without needing a trailing slash on the pattern

And it is the correct behaviour. The bug is when it doesn’t treat the src/ the same as src