···2076207620772077Run tests in an isolated environment. This option has no effect on `vmThreads` pool.
2078207820792079-Disabling this option might improve [performance](/guide/performance) if your code doesn't rely on side effects (which is usually true for projects with `node` environment).
20792079+Disabling this option might [improve performance](/guide/improving-performance) if your code doesn't rely on side effects (which is usually true for projects with `node` environment).
2080208020812081::: note
20822082You can disable isolation for specific pools by using [`poolOptions`](#pooloptions) property.
+51
docs/guide/improving-performance.md
···11+# Improving Performance
22+33+By default Vitest runs every test file in an isolated environment based on the [pool](/config/#pool):
44+55+- `threads` pool runs every test file in a separate [`Worker`](https://nodejs.org/api/worker_threads.html#class-worker)
66+- `forks` pool runs every test file in a separate [forked child process](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
77+- `vmThreads` pool runs every test file in a separate [VM context](https://nodejs.org/api/vm.html#vmcreatecontextcontextobject-options), but it uses workers for parallelism
88+99+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`](/config/#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.
1010+1111+::: code-group
1212+```bash [CLI]
1313+vitest --no-isolate
1414+```
1515+```ts [vitest.config.js]
1616+import { defineConfig } from 'vitest/config'
1717+1818+export default defineConfig({
1919+ test: {
2020+ isolate: false,
2121+ // you can also disable isolation only for specific pools
2222+ poolOptions: {
2323+ forks: {
2424+ isolate: false,
2525+ },
2626+ },
2727+ },
2828+})
2929+```
3030+:::
3131+3232+::: note
3333+If you are using `vmThreads` pool, you cannot disable isolation. Use `threads` pool instead to improve your tests performance.
3434+:::
3535+3636+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`](/config/#fileParallelism) property in the config to `false`.
3737+3838+::: code-group
3939+```bash [CLI]
4040+vitest --no-file-parallelism
4141+```
4242+```ts [vitest.config.js]
4343+import { defineConfig } from 'vitest/config'
4444+4545+export default defineConfig({
4646+ test: {
4747+ fileParallelism: false,
4848+ },
4949+})
5050+```
5151+:::
-51
docs/guide/performance.md
···11-# Performance
22-33-By default Vitest runs every test file in an isolated environment based on the [pool](/config/#pool):
44-55-- `threads` pool runs every test file in a separate [`Worker`](https://nodejs.org/api/worker_threads.html#class-worker)
66-- `forks` pool runs every test file in a separate [forked child process](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
77-- `vmThreads` pool runs every test file in a separate [VM context](https://nodejs.org/api/vm.html#vmcreatecontextcontextobject-options), but it uses workers for parallelism
88-99-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`](/config/#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.
1010-1111-::: code-group
1212-```bash [CLI]
1313-vitest --no-isolate
1414-```
1515-```ts [vitest.config.js]
1616-import { defineConfig } from 'vitest/config'
1717-1818-export default defineConfig({
1919- test: {
2020- isolate: false,
2121- // you can also disable isolation only for specific pools
2222- poolOptions: {
2323- forks: {
2424- isolate: false,
2525- },
2626- },
2727- },
2828-})
2929-```
3030-:::
3131-3232-::: note
3333-If you are using `vmThreads` pool, you cannot disable isolation. Use `threads` pool instead to improve your tests performance.
3434-:::
3535-3636-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`](/config/#fileParallelism) property in the config to `false`.
3737-3838-::: code-group
3939-```bash [CLI]
4040-vitest --no-file-parallelism
4141-```
4242-```ts [vitest.config.js]
4343-import { defineConfig } from 'vitest/config'
4444-4545-export default defineConfig({
4646- test: {
4747- fileParallelism: false,
4848- },
4949-})
5050-```
5151-:::