1
1
import { promises as fs } from 'node:fs'
2
2
import fg from 'fast-glob'
3
3
import mm from 'micromatch'
4
- import { dirname , join , relative , resolve , toNamespacedPath } from 'pathe'
4
+ import { dirname , isAbsolute , join , relative , resolve , toNamespacedPath } from 'pathe'
5
5
import type { TransformResult , ViteDevServer , InlineConfig as ViteInlineConfig } from 'vite'
6
6
import { ViteNodeRunner } from 'vite-node/client'
7
7
import { ViteNodeServer } from 'vite-node/server'
@@ -257,7 +257,7 @@ export class WorkspaceProject {
257
257
return code . includes ( 'import.meta.vitest' )
258
258
}
259
259
260
- filterFiles ( testFiles : string [ ] , filters : string [ ] = [ ] , dir : string ) {
260
+ filterFiles ( testFiles : string [ ] , filters : string [ ] , dir : string ) {
261
261
if ( filters . length && process . platform === 'win32' )
262
262
filters = filters . map ( f => toNamespacedPath ( f ) )
263
263
@@ -266,6 +266,16 @@ export class WorkspaceProject {
266
266
const testFile = relative ( dir , t ) . toLocaleLowerCase ( )
267
267
return filters . some ( ( f ) => {
268
268
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
+
269
279
return testFile . includes ( f . toLocaleLowerCase ( ) ) || testFile . includes ( relativePath . toLocaleLowerCase ( ) )
270
280
} )
271
281
} )
0 commit comments