You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/advanced/pool.md
+21-4Lines changed: 21 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ Vitest runs tests in pools. By default, there are several pools:
14
14
15
15
You can provide your own pool by specifying a file path:
16
16
17
-
```ts
17
+
```ts [vitest.config.ts]
18
18
import { defineConfig } from'vitest/config'
19
19
20
20
exportdefaultdefineConfig({
@@ -27,14 +27,31 @@ export default defineConfig({
27
27
customProperty: true,
28
28
},
29
29
},
30
-
// you can also specify pool for a subset of files
31
-
poolMatchGlobs: [
32
-
['**/*.custom.test.ts', './my-custom-pool.ts'],
30
+
},
31
+
})
32
+
```
33
+
34
+
If you need to run tests in different pools, use the [workspace](/guide/workspace) feature:
35
+
36
+
```ts [vitest.config.ts]
37
+
exportdefaultdefineConfig({
38
+
test: {
39
+
workspace: [
40
+
{
41
+
extends: true,
42
+
test: {
43
+
pool: 'threads',
44
+
},
45
+
},
33
46
],
34
47
},
35
48
})
36
49
```
37
50
51
+
::: info
52
+
The `workspace` field was introduced in Vitest 2.2. To define a workspace in Vitest <2.2, create a separate `vitest.workspace.ts` file.
53
+
:::
54
+
38
55
## API
39
56
40
57
The file specified in `pool` option should export a function (can be async) that accepts `Vitest` interface as its first option. This function needs to return an object matching `ProcessPool` interface:
Copy file name to clipboardExpand all lines: docs/guide/improving-performance.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ By default Vitest runs every test file in an isolated environment based on the [
8
8
-`forks` pool runs every test file in a separate [forked child process](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
9
9
-`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
10
10
11
-
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.
11
+
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`.
0 commit comments