@@ -68,7 +68,7 @@ export class Vitest {
6868 invalidates : Set < string > = new Set ( )
6969 changedTests : Set < string > = new Set ( )
7070 watchedTests : Set < string > = new Set ( )
71- filenamePattern ?: string
71+ filenamePattern ?: string [ ]
7272 runningPromise ?: Promise < void >
7373 closingPromise ?: Promise < void >
7474 isCancelling = false
@@ -418,6 +418,7 @@ export class Vitest {
418418 await this . report ( 'onInit' , this )
419419 }
420420
421+ this . filenamePattern = filters && filters ?. length > 0 ? filters : undefined
421422 const files = await this . filterTestsBySource (
422423 await this . globTestFiles ( filters ) ,
423424 )
@@ -714,7 +715,7 @@ export class Vitest {
714715 }
715716
716717 if ( this . filenamePattern ) {
717- const filteredFiles = await this . globTestFiles ( [ this . filenamePattern ] )
718+ const filteredFiles = await this . globTestFiles ( this . filenamePattern )
718719 files = files . filter ( file => filteredFiles . some ( f => f [ 1 ] === file ) )
719720 }
720721
@@ -778,9 +779,9 @@ export class Vitest {
778779 }
779780
780781 async changeFilenamePattern ( pattern : string , files : string [ ] = this . state . getFilepaths ( ) ) {
781- this . filenamePattern = pattern
782+ this . filenamePattern = pattern ? [ pattern ] : [ ]
782783
783- const trigger = this . filenamePattern ? 'change filename pattern' : 'reset filename pattern'
784+ const trigger = this . filenamePattern . length ? 'change filename pattern' : 'reset filename pattern'
784785
785786 await this . rerunFiles ( files , trigger , pattern === '' )
786787 }
@@ -848,7 +849,7 @@ export class Vitest {
848849 let files = Array . from ( this . changedTests )
849850
850851 if ( this . filenamePattern ) {
851- const filteredFiles = await this . globTestFiles ( [ this . filenamePattern ] )
852+ const filteredFiles = await this . globTestFiles ( this . filenamePattern )
852853 files = files . filter ( file => filteredFiles . some ( f => f [ 1 ] === file ) )
853854
854855 // A file that does not match the current filename pattern was changed
0 commit comments