Skip to content
Vitest 1
Main Navigation GuideAPIConfigAdvanced
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

Guide

Why Vitest

Getting Started

Features

Workspace

CLI

Test Filtering

Reporters

Coverage

Snapshot

Mocking

Testing Types

Vitest UI

Browser Mode

In-source Testing

Test Context

Environment

Extending Matchers

IDE Integration

Debugging

Comparisons

Migration Guide

Common Errors

Improving Performance

API

Test API Reference

Mock Functions

Vi Utility

Expect

ExpectTypeOf

assert

assertType

Config

Config File

Config Reference

On this page

Improving Performance ​

By default Vitest runs every test file in an isolated environment based on the pool:

  • threads pool runs every test file in a separate Worker
  • forks pool runs every test file in a separate forked child process
  • vmThreads pool runs every test file in a separate VM context, but it uses workers for parallelism

This greatly increases test times, which might not be desirable for projects that don't rely on side effects and properly cleanup their state (which is usually true for projects with node environment). In this case disabling isolation will improve the speed of your tests. To do that, you can provide --no-isolate flag to the CLI or set test.isolate property in the config to false. If you are using several pools at once with poolMatchGlobs, you can also disable isolation for a specific pool you are using.

bash
vitest --no-isolate
ts
import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    isolate: false,
    // you can also disable isolation only for specific pools
    poolOptions: {
      forks: {
        isolate: false,
      },
    },
  },
});

TIP

If you are using vmThreads pool, you cannot disable isolation. Use threads pool instead to improve your tests performance.

For some projects, it might also be desirable to disable parallelism to improve startup time. To do that, provide --no-file-parallelism flag to the CLI or set test.fileParallelism property in the config to false.

bash
vitest --no-file-parallelism
ts
import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    fileParallelism: false,
  },
});
Pager
Previous pageCommon Errors
Next pageTest API Reference

Released under the MIT License.

Copyright (c) 2021-Present Vitest Team

https://v1.vitest.dev/guide/improving-performance

Released under the MIT License.

Copyright (c) 2021-Present Vitest Team