@@ -17,8 +17,8 @@ import { WebSocketReporter } from '../api/setup'
1717import type { SerializedCoverageConfig } from '../runtime/config'
1818import type { SerializedSpec } from '../runtime/types/utils'
1919import type { ArgumentsType , OnServerRestartHandler , ProvidedContext , UserConsoleLog } from '../types/general'
20- import { createPool , getFilePoolName } from './pool'
2120import type { ProcessPool , WorkspaceSpec } from './pool'
21+ import { createPool , getFilePoolName } from './pool'
2222import { createBenchmarkReporters , createReporters } from './reporters/utils'
2323import { StateManager } from './state'
2424import { resolveConfig } from './config/resolveConfig'
@@ -437,7 +437,7 @@ export class Vitest {
437437 }
438438 }
439439
440- private async getTestDependencies ( [ project , filepath ] : WorkspaceSpec , deps = new Set < string > ( ) ) {
440+ private async getTestDependencies ( spec : WorkspaceSpec , deps = new Set < string > ( ) ) {
441441 const addImports = async ( project : WorkspaceProject , filepath : string ) => {
442442 if ( deps . has ( filepath ) ) {
443443 return
@@ -459,8 +459,8 @@ export class Vitest {
459459 } ) )
460460 }
461461
462- await addImports ( project , filepath )
463- deps . delete ( filepath )
462+ await addImports ( spec . project . workspaceProject , spec . moduleId )
463+ deps . delete ( spec . moduleId )
464464
465465 return deps
466466 }
@@ -531,18 +531,18 @@ export class Vitest {
531531 for ( const project of this . projects ) {
532532 if ( project . isTestFile ( file ) ) {
533533 const pool = getFilePoolName ( project , file )
534- specs . push ( [ project , file , { pool } ] )
534+ specs . push ( project . createSpec ( file , pool ) )
535535 }
536536 if ( project . isTypecheckFile ( file ) ) {
537- specs . push ( [ project , file , { pool : 'typescript' } ] )
537+ specs . push ( project . createSpec ( file , 'typescript' ) )
538538 }
539539 }
540540 specs . forEach ( spec => this . ensureSpecCached ( spec ) )
541541 return specs
542542 }
543543
544544 async initializeGlobalSetup ( paths : WorkspaceSpec [ ] ) {
545- const projects = new Set ( paths . map ( ( [ project ] ) => project ) )
545+ const projects = new Set ( paths . map ( spec => spec . project . workspaceProject ) )
546546 const coreProject = this . getCoreWorkspaceProject ( )
547547 if ( ! projects . has ( coreProject ) ) {
548548 projects . add ( coreProject )
@@ -566,16 +566,16 @@ export class Vitest {
566566 async runFiles ( specs : WorkspaceSpec [ ] , allTestsRun : boolean ) {
567567 await this . initializeDistPath ( )
568568
569- const filepaths = specs . map ( ( [ , file ] ) => file )
569+ const filepaths = specs . map ( spec => spec . moduleId )
570570 this . state . collectPaths ( filepaths )
571571
572572 await this . report ( 'onPathsCollected' , filepaths )
573573 await this . report ( 'onSpecsCollected' , specs . map (
574- ( [ project , file , options ] ) =>
574+ spec =>
575575 [ {
576- name : project . config . name ,
577- root : project . config . root ,
578- } , file , options ] satisfies SerializedSpec ,
576+ name : spec . project . config . name ,
577+ root : spec . project . config . root ,
578+ } , spec . moduleId , { pool : spec . pool } ] satisfies SerializedSpec ,
579579 ) )
580580
581581 // previous run
@@ -618,7 +618,7 @@ export class Vitest {
618618 } ) ( )
619619 . finally ( async ( ) => {
620620 // can be duplicate files if different projects are using the same file
621- const files = Array . from ( new Set ( specs . map ( ( [ , p ] ) => p ) ) )
621+ const files = Array . from ( new Set ( specs . map ( spec => spec . moduleId ) ) )
622622 const coverage = await this . coverageProvider ?. generateCoverage ( { allTestsRun } )
623623
624624 await this . report ( 'onFinished' , this . state . getFiles ( files ) , this . state . getUnhandledErrors ( ) , coverage )
@@ -638,7 +638,7 @@ export class Vitest {
638638 async collectFiles ( specs : WorkspaceSpec [ ] ) {
639639 await this . initializeDistPath ( )
640640
641- const filepaths = specs . map ( ( [ , file ] ) => file )
641+ const filepaths = specs . map ( spec => spec . moduleId )
642642 this . state . collectPaths ( filepaths )
643643
644644 // previous run
@@ -709,7 +709,7 @@ export class Vitest {
709709 else { this . configOverride . project = pattern }
710710
711711 this . projects = this . resolvedProjects . filter ( p => p . getName ( ) === pattern )
712- const files = ( await this . globTestFiles ( ) ) . map ( ( [ , file ] ) => file )
712+ const files = ( await this . globTestSpecs ( ) ) . map ( spec => spec . moduleId )
713713 await this . rerunFiles ( files , 'change project filter' )
714714 }
715715
@@ -1083,28 +1083,35 @@ export class Vitest {
10831083 }
10841084
10851085 public async getTestFilepaths ( ) {
1086- return this . globTestFiles ( ) . then ( files => files . map ( ( [ , file ] ) => file ) )
1086+ return this . globTestSpecs ( ) . then ( specs => specs . map ( spec => spec . moduleId ) )
10871087 }
10881088
1089- public async globTestFiles ( filters : string [ ] = [ ] ) {
1089+ public async globTestSpecs ( filters : string [ ] = [ ] ) {
10901090 const files : WorkspaceSpec [ ] = [ ]
10911091 await Promise . all ( this . projects . map ( async ( project ) => {
10921092 const { testFiles, typecheckTestFiles } = await project . globTestFiles ( filters )
10931093 testFiles . forEach ( ( file ) => {
10941094 const pool = getFilePoolName ( project , file )
1095- const spec : WorkspaceSpec = [ project , file , { pool } ]
1095+ const spec = project . createSpec ( file , pool )
10961096 this . ensureSpecCached ( spec )
10971097 files . push ( spec )
10981098 } )
10991099 typecheckTestFiles . forEach ( ( file ) => {
1100- const spec : WorkspaceSpec = [ project , file , { pool : 'typescript' } ]
1100+ const spec = project . createSpec ( file , 'typescript' )
11011101 this . ensureSpecCached ( spec )
11021102 files . push ( spec )
11031103 } )
11041104 } ) )
11051105 return files
11061106 }
11071107
1108+ /**
1109+ * @deprecated use globTestSpecs instead
1110+ */
1111+ public async globTestFiles ( filters : string [ ] = [ ] ) {
1112+ return this . globTestSpecs ( filters )
1113+ }
1114+
11081115 private ensureSpecCached ( spec : WorkspaceSpec ) {
11091116 const file = spec [ 1 ]
11101117 const specs = this . _cachedSpecs . get ( file ) || [ ]
0 commit comments