Skip to content

Commit

Permalink
fix(config): type issue of pool and poolMatchGlobs in defineConfig (
Browse files Browse the repository at this point in the history
  • Loading branch information
InfiniteXyy authored Oct 13, 2023
1 parent e836b2b commit 9112cc9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/vitest/src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 2 additions & 5 deletions packages/vitest/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion packages/vitest/src/node/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions packages/vitest/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export interface InlineConfig {
*
* @default 'threads'
*/
pool?: Omit<Pool, 'browser'>
pool?: Exclude<Pool, 'browser'>

/**
* Pool options
Expand All @@ -314,7 +314,7 @@ export interface InlineConfig {
* // ...
* ]
*/
poolMatchGlobs?: [string, Omit<Pool, 'browser'>][]
poolMatchGlobs?: [string, Exclude<Pool, 'browser'>][]

/**
* Update snapshot
Expand Down Expand Up @@ -704,7 +704,7 @@ export interface UserConfig extends InlineConfig {
shard?: string
}

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

base?: string
Expand Down

0 comments on commit 9112cc9

Please sign in to comment.