@@ -27,6 +27,28 @@ export interface PoolProcessOptions {
27
27
28
28
export const builtinPools : BuiltinPool [ ] = [ 'forks' , 'threads' , 'browser' , 'vmThreads' , 'vmForks' , 'typescript' ]
29
29
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
+
30
52
export function createPool ( ctx : Vitest ) : ProcessPool {
31
53
const pools : Record < Pool , ProcessPool | null > = {
32
54
forks : null ,
@@ -37,28 +59,6 @@ export function createPool(ctx: Vitest): ProcessPool {
37
59
typescript : null ,
38
60
}
39
61
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
-
62
62
// in addition to resolve.conditions Vite also adds production/development,
63
63
// see: https://github.com/vitejs/vite/blob/af2aa09575229462635b7cbb6d248ca853057ba2/packages/vite/src/node/plugins/resolve.ts#L1056-L1080
64
64
const potentialConditions = new Set ( [ 'production' , 'development' , ...ctx . server . config . resolve . conditions ] )
@@ -137,7 +137,7 @@ export function createPool(ctx: Vitest): ProcessPool {
137
137
}
138
138
139
139
for ( const spec of files ) {
140
- const pool = getPoolName ( spec )
140
+ const pool = getFilePoolName ( spec [ 0 ] , spec [ 1 ] )
141
141
filesByPool [ pool ] ??= [ ]
142
142
filesByPool [ pool ] . push ( spec )
143
143
}
0 commit comments