W3cubDocs

/Vitest

maxWorkers

  • Type: number | string
  • Default:
    • if watch is disabled, uses all available parallelism
    • if watch is enabled, uses half of all available parallelism

Defines the maximum concurrency for test workers. Accepts either a number or a percentage string.

  • Number: spawns up to the specified number of workers.
  • Percentage string (e.g., "50%"): computes the worker count as the given percentage of the machine’s available parallelism.

Example

Number

import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    maxWorkers: 4,
  },
})
vitest --maxWorkers=4

Percent

import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    maxWorkers: '50%',
  },
})
vitest --maxWorkers=50%

Vitest uses os.availableParallelism to know the maximum amount of parallelism available.

© 2021-Present VoidZero Inc. and Vitest contributors
Licensed under the MIT License.
https://vitest.dev/config/maxworkers