Skip to content

Commit

Permalink
fix(vitest): don't hang with maxConcurrency 0
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Oct 3, 2024
1 parent 46be62c commit 4da333b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/vitest/src/node/config/resolveConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ export function resolveConfig(
resolved.minWorkers = 1
}

if (resolved.maxConcurrency === 0) {
logger.console.warn(
c.yellow(`The option "maxConcurrency" cannot be set to 0. Using default value ${configDefaults.maxConcurrency} instead.`),
)
resolved.maxConcurrency = configDefaults.maxConcurrency
}

if (resolved.inspect || resolved.inspectBrk) {
const isSingleThread
= resolved.pool === 'threads'
Expand Down
7 changes: 7 additions & 0 deletions test/config/test/failures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,10 @@ test('mergeReports doesn\'t work with watch mode enabled', async () => {

expect(stderr).toMatch('Cannot merge reports with --watch enabled')
})

test('maxConcurrency 0 prints a warning', async () => {
const { stderr, ctx } = await runVitest({ maxConcurrency: 0 })

expect(ctx?.config.maxConcurrency).toBe(5)
expect(stderr).toMatch('The option "maxConcurrency" cannot be set to 0. Using default value 5 instead.')
})
1 change: 1 addition & 0 deletions test/config/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default defineConfig({
truncateThreshold: 999,
},
coverage: {
// test that empty reporter does not throw
reporter: [],
},
},
Expand Down

0 comments on commit 4da333b

Please sign in to comment.