Skip to content
Vitest 3
Main Navigation Guide & APIConfigBrowser ModeAdvanced API
3.2.0
2.1.9
1.6.1
0.34.6

English

简体中文
繁體中文
Español
Français
Русский
Português – Brasil
Deutsch
日本語
한국어
Italiano
Polski
Türkçe
čeština
magyar

English

简体中文
繁體中文
Español
Français
Русский
Português – Brasil
Deutsch
日本語
한국어
Italiano
Polski
Türkçe
čeština
magyar

Appearance

Sidebar Navigation

Introduction

Why Vitest

Getting Started

Features

Config Reference

API

Test API Reference

Mock Functions

Vi Utility

Expect

ExpectTypeOf

Assert

AssertType

Guides

CLI

Test Filtering

Test Projects

Reporters

Coverage

Snapshot

Mocking

Parallelism

Testing Types

Vitest UI

In-Source Testing

Test Context

Test Annotations

Environment

Extending Matchers

IDE Integration

Debugging

Common Errors

Migration Guide

Migrating to Vitest 3.0

Migrating from Jest

Performance

Profiling Test Performance

Improving Performance

Browser Mode

Node API Reference

Comparisons

On this page

Parallelism ​

File Parallelism ​

By default, Vitest runs test files in parallel. Depending on the specified pool, Vitest uses a different mechanism to parallelize test files:

  • forks (the default) and vmForks run tests in different child processes
  • threads and vmThreads run tests in different worker threads

Both "child processes" and "worker threads" are refered to as "workers". You can configure the number of running workers with minWorkers and maxWorkers options. Or more granually with poolOptions configuration.

If you have a lot of tests, it is usually faster to run them in parallel, but it also depends on the project, the environment and isolation state. To disable file parallelisation, you can set fileParallelism to false. To learn more about possible performance improvements, read the Performance Guide.

Test Parallelism ​

Unlike test files, Vitest runs tests in sequence. This means that tests inside a single test file will run in the order they are defined.

Vitest supports the concurrent option to run tests together. If this option is set, Vitest will group concurrent tests in the same file (the number of simultaneously running tests depends on the maxConcurrency option) and run them with Promise.all.

Vitest doesn't perform any smart analysis and doesn't create additional workers to run these tests. This means that the performance of your tests will improve only if you rely heavily on asynchronous operations. For example, these tests will still run one after another even though the concurrent option is specified. This is because they are synchronous:

ts
test.concurrent('the first test', () => {
  expect(1).toBe(1);
});

test.concurrent('the second test', () => {
  expect(2).toBe(2);
});

If you wish to run all tests concurrently, you can set the sequence.concurrent option to true.

Pager
Previous pageMocking
Next pageTesting Types

Released under the MIT License.

Copyright (c) 2021-Present Vitest Team

https://vitest.dev/guide/parallelism

Released under the MIT License.

Copyright (c) 2021-Present Vitest Team