diff --git a/packages/vitest/src/defaults.ts b/packages/vitest/src/defaults.ts index deeed8132..0d44c755e 100644 --- a/packages/vitest/src/defaults.ts +++ b/packages/vitest/src/defaults.ts @@ -62,7 +62,7 @@ const config = { watch: !isCI, globals: false, environment: 'node' as const, - pool: 'threads', + pool: 'threads' as const, clearMocks: false, restoreMocks: false, mockReset: false, diff --git a/packages/vitest/src/node/config.ts b/packages/vitest/src/node/config.ts index c1f472c3b..464b384a2 100644 --- a/packages/vitest/src/node/config.ts +++ b/packages/vitest/src/node/config.ts @@ -398,9 +398,6 @@ export function resolveConfig( return resolved } -export function isBrowserEnabled(config: ResolvedConfig) { - if (config.browser?.enabled) - return true - - return config.poolMatchGlobs?.length && config.poolMatchGlobs.some(([, pool]) => pool === 'browser') +export function isBrowserEnabled(config: ResolvedConfig): boolean { + return Boolean(config.browser?.enabled) } diff --git a/packages/vitest/src/node/pool.ts b/packages/vitest/src/node/pool.ts index 394b6c88b..a1abf634d 100644 --- a/packages/vitest/src/node/pool.ts +++ b/packages/vitest/src/node/pool.ts @@ -46,7 +46,7 @@ export function createPool(ctx: Vitest): ProcessPool { function getPoolName([project, file]: WorkspaceSpec) { for (const [glob, pool] of project.config.poolMatchGlobs || []) { - if (pool === 'browser') + if ((pool as Pool) === 'browser') 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') if (mm.isMatch(file, glob, { cwd: project.config.root })) return pool as Pool diff --git a/packages/vitest/src/types/config.ts b/packages/vitest/src/types/config.ts index 70c5338bd..4bc137329 100644 --- a/packages/vitest/src/types/config.ts +++ b/packages/vitest/src/types/config.ts @@ -294,7 +294,7 @@ export interface InlineConfig { * * @default 'threads' */ - pool?: Omit + pool?: Exclude /** * Pool options @@ -314,7 +314,7 @@ export interface InlineConfig { * // ... * ] */ - poolMatchGlobs?: [string, Omit][] + poolMatchGlobs?: [string, Exclude][] /** * Update snapshot @@ -704,7 +704,7 @@ export interface UserConfig extends InlineConfig { shard?: string } -export interface ResolvedConfig extends Omit, 'config' | 'filters' | 'browser' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner' | 'poolOptions'> { +export interface ResolvedConfig extends Omit, 'config' | 'filters' | 'browser' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner' | 'poolOptions' | 'pool'> { mode: VitestRunMode base?: string