Skip to content

Commit f377a3b

Browse files
authored
fix: respect trailing slash when filtering by file path (#4538)
1 parent 2b2416d commit f377a3b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/vitest/src/node/workspace.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { promises as fs } from 'node:fs'
22
import fg from 'fast-glob'
33
import mm from 'micromatch'
4-
import { dirname, relative, resolve, toNamespacedPath } from 'pathe'
4+
import { dirname, join, relative, resolve, toNamespacedPath } from 'pathe'
55
import type { TransformResult, ViteDevServer, InlineConfig as ViteInlineConfig } from 'vite'
66
import { ViteNodeRunner } from 'vite-node/client'
77
import { ViteNodeServer } from 'vite-node/server'
@@ -254,7 +254,8 @@ export class WorkspaceProject {
254254
return testFiles.filter((t) => {
255255
const testFile = relative(dir, t)
256256
return filters.some((f) => {
257-
return testFile.includes(f) || testFile.includes(relative(dir, f))
257+
const relativePath = f.endsWith('/') ? join(relative(dir, f), '/') : relative(dir, f)
258+
return testFile.includes(f) || testFile.includes(relativePath)
258259
})
259260
})
260261
}

0 commit comments

Comments
 (0)