Skip to content

Commit

Permalink
fix(vitest): only consider cwd when using glob (fix #3802) (#3949)
Browse files Browse the repository at this point in the history
  • Loading branch information
g-plane committed Aug 15, 2023
1 parent 7b740a2 commit 15b4fd6
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -27,3 +27,4 @@ docs/public/user-avatars
docs/public/sponsors
.eslintcache
docs/.vitepress/cache/
!test/cwd/**/.cache
4 changes: 2 additions & 2 deletions packages/vitest/src/node/workspace.ts
Expand Up @@ -145,13 +145,13 @@ export class WorkspaceProject {

async globFiles(include: string[], exclude: string[], cwd: string) {
const globOptions: fg.Options = {
absolute: true,
dot: true,
cwd,
ignore: exclude,
}

return fg(include, globOptions)
const files = await fg(include, globOptions)
return files.map(file => resolve(cwd, file))
}

async isTargetFile(id: string, source?: string): Promise<boolean> {
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions test/cwd/.cache/projects/test/.cache/should-not-run.test.ts
@@ -0,0 +1,5 @@
import { expect, test } from 'vitest'

test('should not run', () => {
expect(1).toBe(2)
})
5 changes: 5 additions & 0 deletions test/cwd/.cache/projects/test/should-run.test.ts
@@ -0,0 +1,5 @@
import { expect, test } from 'vitest'

test('should run', () => {
expect(1).toBe(1)
})
10 changes: 10 additions & 0 deletions test/cwd/package.json
@@ -0,0 +1,10 @@
{
"name": "@vitest/test-cwd",
"private": true,
"scripts": {
"test": "cd $(pwd)/.cache/projects/test && vitest run"
},
"devDependencies": {
"vitest": "workspace:*"
}
}
3 changes: 3 additions & 0 deletions test/cwd/vitest.config.ts
@@ -0,0 +1,3 @@
import { defineConfig } from 'vitest/config'

export default defineConfig({})

0 comments on commit 15b4fd6

Please sign in to comment.