@@ -27,6 +27,28 @@ export interface PoolProcessOptions {
2727
2828export const builtinPools : BuiltinPool [ ] = [ 'forks' , 'threads' , 'browser' , 'vmThreads' , 'vmForks' , 'typescript' ]
2929
30+ function getDefaultPoolName ( project : WorkspaceProject , file : string ) : Pool {
31+ if ( project . config . typecheck . enabled ) {
32+ for ( const glob of project . config . typecheck . include ) {
33+ if ( mm . isMatch ( file , glob , { cwd : project . config . root } ) )
34+ return 'typescript'
35+ }
36+ }
37+ if ( project . config . browser . enabled )
38+ return 'browser'
39+ return project . config . pool
40+ }
41+
42+ export function getFilePoolName ( project : WorkspaceProject , file : string ) {
43+ for ( const [ glob , pool ] of project . config . poolMatchGlobs ) {
44+ if ( ( pool as Pool ) === 'browser' )
45+ throw new Error ( 'Since Vitest 0.31.0 "browser" pool is not supported in "poolMatchGlobs". You can create a workspace to run some of your tests in browser in parallel. Read more: https://vitest.dev/guide/workspace' )
46+ if ( mm . isMatch ( file , glob , { cwd : project . config . root } ) )
47+ return pool as Pool
48+ }
49+ return getDefaultPoolName ( project , file )
50+ }
51+
3052export function createPool ( ctx : Vitest ) : ProcessPool {
3153 const pools : Record < Pool , ProcessPool | null > = {
3254 forks : null ,
@@ -37,28 +59,6 @@ export function createPool(ctx: Vitest): ProcessPool {
3759 typescript : null ,
3860 }
3961
40- function getDefaultPoolName ( project : WorkspaceProject , file : string ) : Pool {
41- if ( project . config . typecheck . enabled ) {
42- for ( const glob of project . config . typecheck . include ) {
43- if ( mm . isMatch ( file , glob , { cwd : project . config . root } ) )
44- return 'typescript'
45- }
46- }
47- if ( project . config . browser . enabled )
48- return 'browser'
49- return project . config . pool
50- }
51-
52- function getPoolName ( [ project , file ] : WorkspaceSpec ) {
53- for ( const [ glob , pool ] of project . config . poolMatchGlobs ) {
54- if ( ( pool as Pool ) === 'browser' )
55- throw new Error ( 'Since Vitest 0.31.0 "browser" pool is not supported in "poolMatchGlobs". You can create a workspace to run some of your tests in browser in parallel. Read more: https://vitest.dev/guide/workspace' )
56- if ( mm . isMatch ( file , glob , { cwd : project . config . root } ) )
57- return pool as Pool
58- }
59- return getDefaultPoolName ( project , file )
60- }
61-
6262 // in addition to resolve.conditions Vite also adds production/development,
6363 // see: https://github.com/vitejs/vite/blob/af2aa09575229462635b7cbb6d248ca853057ba2/packages/vite/src/node/plugins/resolve.ts#L1056-L1080
6464 const potentialConditions = new Set ( [ 'production' , 'development' , ...ctx . server . config . resolve . conditions ] )
@@ -137,7 +137,7 @@ export function createPool(ctx: Vitest): ProcessPool {
137137 }
138138
139139 for ( const spec of files ) {
140- const pool = getPoolName ( spec )
140+ const pool = getFilePoolName ( spec [ 0 ] , spec [ 1 ] )
141141 filesByPool [ pool ] ??= [ ]
142142 filesByPool [ pool ] . push ( spec )
143143 }
0 commit comments