11import * as nodeos from 'node:os'
22import crypto from 'node:crypto'
33import { relative } from 'pathe'
4- import type { BrowserProvider , ProcessPool , Vitest , WorkspaceProject , WorkspaceSpec } from 'vitest/node'
4+ import type { BrowserProvider , ProcessPool , TestProject , TestSpecification , Vitest } from 'vitest/node'
55import { createDebugger } from 'vitest/node'
66
77const debug = createDebugger ( 'vitest:browser:pool' )
@@ -12,15 +12,15 @@ export function createBrowserPool(ctx: Vitest): ProcessPool {
1212 const waitForTests = async (
1313 method : 'run' | 'collect' ,
1414 contextId : string ,
15- project : WorkspaceProject ,
15+ project : TestProject ,
1616 files : string [ ] ,
1717 ) => {
1818 const context = project . browser ! . state . createAsyncContext ( method , contextId , files )
1919 return await context
2020 }
2121
22- const executeTests = async ( method : 'run' | 'collect' , project : WorkspaceProject , files : string [ ] ) => {
23- ctx . state . clearFiles ( project , files )
22+ const executeTests = async ( method : 'run' | 'collect' , project : TestProject , files : string [ ] ) => {
23+ ctx . state . clearFiles ( project . workspaceProject , files )
2424 const browser = project . browser !
2525
2626 const threadsCount = getThreadsCount ( project )
@@ -33,7 +33,7 @@ export function createBrowserPool(ctx: Vitest): ProcessPool {
3333
3434 if ( ! origin ) {
3535 throw new Error (
36- `Can't find browser origin URL for project "${ project . getName ( ) } " when running tests for files "${ files . join ( '", "' ) } "` ,
36+ `Can't find browser origin URL for project "${ project . name } " when running tests for files "${ files . join ( '", "' ) } "` ,
3737 )
3838 }
3939
@@ -50,7 +50,7 @@ export function createBrowserPool(ctx: Vitest): ProcessPool {
5050
5151 debug ?.(
5252 `[%s] Running %s tests in %s chunks (%s threads)` ,
53- project . getName ( ) || 'core' ,
53+ project . name || 'core' ,
5454 files . length ,
5555 chunks . length ,
5656 threadsCount ,
@@ -92,12 +92,12 @@ export function createBrowserPool(ctx: Vitest): ProcessPool {
9292 await Promise . all ( promises )
9393 }
9494
95- const runWorkspaceTests = async ( method : 'run' | 'collect' , specs : WorkspaceSpec [ ] ) => {
96- const groupedFiles = new Map < WorkspaceProject , string [ ] > ( )
97- for ( const [ project , file ] of specs ) {
98- const files = groupedFiles . get ( project ) || [ ]
99- files . push ( file )
100- groupedFiles . set ( project , files )
95+ const runWorkspaceTests = async ( method : 'run' | 'collect' , specs : TestSpecification [ ] ) => {
96+ const groupedFiles = new Map < TestProject , string [ ] > ( )
97+ for ( const spec of specs ) {
98+ const files = groupedFiles . get ( spec . project ) || [ ]
99+ files . push ( spec . moduleId )
100+ groupedFiles . set ( spec . project , files )
101101 }
102102
103103 let isCancelled = false
@@ -120,7 +120,7 @@ export function createBrowserPool(ctx: Vitest): ProcessPool {
120120 ? nodeos . availableParallelism ( )
121121 : nodeos . cpus ( ) . length
122122
123- function getThreadsCount ( project : WorkspaceProject ) {
123+ function getThreadsCount ( project : TestProject ) {
124124 const config = project . config . browser
125125 if ( ! config . headless || ! project . browser ! . provider . supportsParallelism ) {
126126 return 1
0 commit comments