Skip to content

Commit 9112cc9

Browse files
authoredOct 13, 2023
fix(config): type issue of pool and poolMatchGlobs in defineConfig (#4282)
1 parent e836b2b commit 9112cc9

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed
 

Diff for: ‎packages/vitest/src/defaults.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const config = {
6262
watch: !isCI,
6363
globals: false,
6464
environment: 'node' as const,
65-
pool: 'threads',
65+
pool: 'threads' as const,
6666
clearMocks: false,
6767
restoreMocks: false,
6868
mockReset: false,

Diff for: ‎packages/vitest/src/node/config.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,6 @@ export function resolveConfig(
398398
return resolved
399399
}
400400

401-
export function isBrowserEnabled(config: ResolvedConfig) {
402-
if (config.browser?.enabled)
403-
return true
404-
405-
return config.poolMatchGlobs?.length && config.poolMatchGlobs.some(([, pool]) => pool === 'browser')
401+
export function isBrowserEnabled(config: ResolvedConfig): boolean {
402+
return Boolean(config.browser?.enabled)
406403
}

Diff for: ‎packages/vitest/src/node/pool.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function createPool(ctx: Vitest): ProcessPool {
4646

4747
function getPoolName([project, file]: WorkspaceSpec) {
4848
for (const [glob, pool] of project.config.poolMatchGlobs || []) {
49-
if (pool === 'browser')
49+
if ((pool as Pool) === 'browser')
5050
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')
5151
if (mm.isMatch(file, glob, { cwd: project.config.root }))
5252
return pool as Pool

Diff for: ‎packages/vitest/src/types/config.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ export interface InlineConfig {
294294
*
295295
* @default 'threads'
296296
*/
297-
pool?: Omit<Pool, 'browser'>
297+
pool?: Exclude<Pool, 'browser'>
298298

299299
/**
300300
* Pool options
@@ -314,7 +314,7 @@ export interface InlineConfig {
314314
* // ...
315315
* ]
316316
*/
317-
poolMatchGlobs?: [string, Omit<Pool, 'browser'>][]
317+
poolMatchGlobs?: [string, Exclude<Pool, 'browser'>][]
318318

319319
/**
320320
* Update snapshot
@@ -704,7 +704,7 @@ export interface UserConfig extends InlineConfig {
704704
shard?: string
705705
}
706706

707-
export interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'browser' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner' | 'poolOptions'> {
707+
export interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'browser' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner' | 'poolOptions' | 'pool'> {
708708
mode: VitestRunMode
709709

710710
base?: string

0 commit comments

Comments
 (0)
Please sign in to comment.