@@ -68,7 +68,7 @@ export class Vitest {
68
68
invalidates : Set < string > = new Set ( )
69
69
changedTests : Set < string > = new Set ( )
70
70
watchedTests : Set < string > = new Set ( )
71
- filenamePattern ?: string
71
+ filenamePattern ?: string [ ]
72
72
runningPromise ?: Promise < void >
73
73
closingPromise ?: Promise < void >
74
74
isCancelling = false
@@ -418,6 +418,7 @@ export class Vitest {
418
418
await this . report ( 'onInit' , this )
419
419
}
420
420
421
+ this . filenamePattern = filters && filters ?. length > 0 ? filters : undefined
421
422
const files = await this . filterTestsBySource (
422
423
await this . globTestFiles ( filters ) ,
423
424
)
@@ -714,7 +715,7 @@ export class Vitest {
714
715
}
715
716
716
717
if ( this . filenamePattern ) {
717
- const filteredFiles = await this . globTestFiles ( [ this . filenamePattern ] )
718
+ const filteredFiles = await this . globTestFiles ( this . filenamePattern )
718
719
files = files . filter ( file => filteredFiles . some ( f => f [ 1 ] === file ) )
719
720
}
720
721
@@ -778,9 +779,9 @@ export class Vitest {
778
779
}
779
780
780
781
async changeFilenamePattern ( pattern : string , files : string [ ] = this . state . getFilepaths ( ) ) {
781
- this . filenamePattern = pattern
782
+ this . filenamePattern = pattern ? [ pattern ] : [ ]
782
783
783
- const trigger = this . filenamePattern ? 'change filename pattern' : 'reset filename pattern'
784
+ const trigger = this . filenamePattern . length ? 'change filename pattern' : 'reset filename pattern'
784
785
785
786
await this . rerunFiles ( files , trigger , pattern === '' )
786
787
}
@@ -848,7 +849,7 @@ export class Vitest {
848
849
let files = Array . from ( this . changedTests )
849
850
850
851
if ( this . filenamePattern ) {
851
- const filteredFiles = await this . globTestFiles ( [ this . filenamePattern ] )
852
+ const filteredFiles = await this . globTestFiles ( this . filenamePattern )
852
853
files = files . filter ( file => filteredFiles . some ( f => f [ 1 ] === file ) )
853
854
854
855
// A file that does not match the current filename pattern was changed
0 commit comments