11import { promises as fs } from 'node:fs'
22import fg from 'fast-glob'
33import mm from 'micromatch'
4- import { dirname , join , relative , resolve , toNamespacedPath } from 'pathe'
4+ import { dirname , isAbsolute , join , relative , resolve , toNamespacedPath } from 'pathe'
55import type { TransformResult , ViteDevServer , InlineConfig as ViteInlineConfig } from 'vite'
66import { ViteNodeRunner } from 'vite-node/client'
77import { ViteNodeServer } from 'vite-node/server'
@@ -257,7 +257,7 @@ export class WorkspaceProject {
257257 return code . includes ( 'import.meta.vitest' )
258258 }
259259
260- filterFiles ( testFiles : string [ ] , filters : string [ ] = [ ] , dir : string ) {
260+ filterFiles ( testFiles : string [ ] , filters : string [ ] , dir : string ) {
261261 if ( filters . length && process . platform === 'win32' )
262262 filters = filters . map ( f => toNamespacedPath ( f ) )
263263
@@ -266,6 +266,16 @@ export class WorkspaceProject {
266266 const testFile = relative ( dir , t ) . toLocaleLowerCase ( )
267267 return filters . some ( ( f ) => {
268268 const relativePath = f . endsWith ( '/' ) ? join ( relative ( dir , f ) , '/' ) : relative ( dir , f )
269+
270+ // if filter is a full file path, we should include it if it's in the same folder
271+ if ( isAbsolute ( f ) ) {
272+ // the file is inside the filter path, so we should always include it,
273+ // we don't include ../file because this condition is always true if
274+ // the file doens't exist which cause false positives
275+ if ( relativePath === '..' || relativePath === '../' || relativePath . startsWith ( '../..' ) )
276+ return true
277+ }
278+
269279 return testFile . includes ( f . toLocaleLowerCase ( ) ) || testFile . includes ( relativePath . toLocaleLowerCase ( ) )
270280 } )
271281 } )
0 commit comments