@vitest-agent/mcp 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/index.d.ts +2 -2
- package/index.js +1 -1
- package/package.json +1 -1
- package/server.js +2 -4
- package/patterns/_meta.json +0 -67
- package/patterns/authoring-a-custom-vitest-agent-reporter.md +0 -82
- package/patterns/known-issues-and-caveats.md +0 -52
- package/patterns/operating-vitest-agent-as-an-agent.md +0 -62
- package/patterns/running-tests-via-mcp.md +0 -103
- package/patterns/silencing-leaking-output-in-tests.md +0 -91
- package/patterns/testing-effect-schema-definitions.md +0 -71
- package/patterns/testing-effect-services-with-mock-layers.md +0 -63
- package/resources/index.js +0 -166
- package/resources/indexes.js +0 -77
- package/resources/manifest-schema.js +0 -46
- package/resources/paths.js +0 -20
- package/resources/patterns.js +0 -22
- package/resources/upstream-docs.js +0 -22
- package/vendor/vitest-docs/ATTRIBUTION.md +0 -5
- package/vendor/vitest-docs/api/advanced/artifacts.md +0 -189
- package/vendor/vitest-docs/api/advanced/metadata.md +0 -68
- package/vendor/vitest-docs/api/advanced/plugin.md +0 -168
- package/vendor/vitest-docs/api/advanced/reporters.md +0 -342
- package/vendor/vitest-docs/api/advanced/runner.md +0 -334
- package/vendor/vitest-docs/api/advanced/test-case.md +0 -302
- package/vendor/vitest-docs/api/advanced/test-collection.md +0 -89
- package/vendor/vitest-docs/api/advanced/test-module.md +0 -140
- package/vendor/vitest-docs/api/advanced/test-project.md +0 -321
- package/vendor/vitest-docs/api/advanced/test-specification.md +0 -96
- package/vendor/vitest-docs/api/advanced/test-suite.md +0 -230
- package/vendor/vitest-docs/api/advanced/vitest.md +0 -684
- package/vendor/vitest-docs/api/assert-type.md +0 -22
- package/vendor/vitest-docs/api/assert.md +0 -1960
- package/vendor/vitest-docs/api/browser/assertions.md +0 -1277
- package/vendor/vitest-docs/api/browser/commands.md +0 -154
- package/vendor/vitest-docs/api/browser/context.md +0 -338
- package/vendor/vitest-docs/api/browser/interactivity.md +0 -681
- package/vendor/vitest-docs/api/browser/locators.md +0 -1171
- package/vendor/vitest-docs/api/browser/react.md +0 -346
- package/vendor/vitest-docs/api/browser/svelte.md +0 -292
- package/vendor/vitest-docs/api/browser/vue.md +0 -222
- package/vendor/vitest-docs/api/describe.md +0 -374
- package/vendor/vitest-docs/api/expect-typeof.md +0 -571
- package/vendor/vitest-docs/api/expect.md +0 -2304
- package/vendor/vitest-docs/api/hooks.md +0 -463
- package/vendor/vitest-docs/api/mock.md +0 -701
- package/vendor/vitest-docs/api/test.md +0 -926
- package/vendor/vitest-docs/api/vi.md +0 -1372
- package/vendor/vitest-docs/config/alias.md +0 -13
- package/vendor/vitest-docs/config/allowonly.md +0 -32
- package/vendor/vitest-docs/config/api.md +0 -27
- package/vendor/vitest-docs/config/attachmentsdir.md +0 -6
- package/vendor/vitest-docs/config/bail.md +0 -9
- package/vendor/vitest-docs/config/benchmark.md +0 -65
- package/vendor/vitest-docs/config/browser/api.md +0 -23
- package/vendor/vitest-docs/config/browser/commands.md +0 -6
- package/vendor/vitest-docs/config/browser/connecttimeout.md +0 -10
- package/vendor/vitest-docs/config/browser/detailspanelposition.md +0 -38
- package/vendor/vitest-docs/config/browser/enabled.md +0 -40
- package/vendor/vitest-docs/config/browser/expect.md +0 -250
- package/vendor/vitest-docs/config/browser/headless.md +0 -7
- package/vendor/vitest-docs/config/browser/instances.md +0 -47
- package/vendor/vitest-docs/config/browser/isolate.md +0 -11
- package/vendor/vitest-docs/config/browser/locators.md +0 -24
- package/vendor/vitest-docs/config/browser/orchestratorscripts.md +0 -39
- package/vendor/vitest-docs/config/browser/playwright.md +0 -214
- package/vendor/vitest-docs/config/browser/preview.md +0 -32
- package/vendor/vitest-docs/config/browser/provider.md +0 -79
- package/vendor/vitest-docs/config/browser/screenshotdirectory.md +0 -6
- package/vendor/vitest-docs/config/browser/screenshotfailures.md +0 -6
- package/vendor/vitest-docs/config/browser/testerhtmlpath.md +0 -5
- package/vendor/vitest-docs/config/browser/trace.md +0 -43
- package/vendor/vitest-docs/config/browser/trackunhandlederrors.md +0 -10
- package/vendor/vitest-docs/config/browser/ui.md +0 -7
- package/vendor/vitest-docs/config/browser/viewport.md +0 -6
- package/vendor/vitest-docs/config/browser/webdriverio.md +0 -64
- package/vendor/vitest-docs/config/cache.md +0 -26
- package/vendor/vitest-docs/config/chaiconfig.md +0 -29
- package/vendor/vitest-docs/config/clearmocks.md +0 -22
- package/vendor/vitest-docs/config/coverage.md +0 -455
- package/vendor/vitest-docs/config/css.md +0 -47
- package/vendor/vitest-docs/config/dangerouslyignoreunhandlederrors.md +0 -23
- package/vendor/vitest-docs/config/deps.md +0 -127
- package/vendor/vitest-docs/config/detectasyncleaks.md +0 -39
- package/vendor/vitest-docs/config/diff.md +0 -96
- package/vendor/vitest-docs/config/dir.md +0 -7
- package/vendor/vitest-docs/config/disableconsoleintercept.md +0 -15
- package/vendor/vitest-docs/config/env.md +0 -5
- package/vendor/vitest-docs/config/environment.md +0 -96
- package/vendor/vitest-docs/config/environmentoptions.md +0 -30
- package/vendor/vitest-docs/config/exclude.md +0 -49
- package/vendor/vitest-docs/config/execargv.md +0 -10
- package/vendor/vitest-docs/config/expandsnapshotdiff.md +0 -7
- package/vendor/vitest-docs/config/expect.md +0 -38
- package/vendor/vitest-docs/config/experimental.md +0 -510
- package/vendor/vitest-docs/config/faketimers.md +0 -51
- package/vendor/vitest-docs/config/fileparallelism.md +0 -11
- package/vendor/vitest-docs/config/forcereruntriggers.md +0 -19
- package/vendor/vitest-docs/config/globals.md +0 -42
- package/vendor/vitest-docs/config/globalsetup.md +0 -72
- package/vendor/vitest-docs/config/hideskippedtests.md +0 -7
- package/vendor/vitest-docs/config/hooktimeout.md +0 -7
- package/vendor/vitest-docs/config/include-source.md +0 -115
- package/vendor/vitest-docs/config/include.md +0 -71
- package/vendor/vitest-docs/config/includetasklocation.md +0 -17
- package/vendor/vitest-docs/config/index.md +0 -85
- package/vendor/vitest-docs/config/isolate.md +0 -13
- package/vendor/vitest-docs/config/logheapusage.md +0 -7
- package/vendor/vitest-docs/config/maxconcurrency.md +0 -9
- package/vendor/vitest-docs/config/maxworkers.md +0 -49
- package/vendor/vitest-docs/config/mockreset.md +0 -22
- package/vendor/vitest-docs/config/mode.md +0 -7
- package/vendor/vitest-docs/config/name.md +0 -111
- package/vendor/vitest-docs/config/onconsolelog.md +0 -25
- package/vendor/vitest-docs/config/onstacktrace.md +0 -32
- package/vendor/vitest-docs/config/onunhandlederror.md +0 -35
- package/vendor/vitest-docs/config/open.md +0 -7
- package/vendor/vitest-docs/config/outputfile.md +0 -7
- package/vendor/vitest-docs/config/passwithnotests.md +0 -7
- package/vendor/vitest-docs/config/pool.md +0 -45
- package/vendor/vitest-docs/config/printconsoletrace.md +0 -6
- package/vendor/vitest-docs/config/projects.md +0 -6
- package/vendor/vitest-docs/config/provide.md +0 -45
- package/vendor/vitest-docs/config/reporters.md +0 -69
- package/vendor/vitest-docs/config/resolvesnapshotpath.md +0 -36
- package/vendor/vitest-docs/config/restoremocks.md +0 -22
- package/vendor/vitest-docs/config/retry.md +0 -140
- package/vendor/vitest-docs/config/root.md +0 -6
- package/vendor/vitest-docs/config/runner.md +0 -6
- package/vendor/vitest-docs/config/sequence.md +0 -158
- package/vendor/vitest-docs/config/server.md +0 -68
- package/vendor/vitest-docs/config/setupfiles.md +0 -40
- package/vendor/vitest-docs/config/silent.md +0 -9
- package/vendor/vitest-docs/config/slowtestthreshold.md +0 -7
- package/vendor/vitest-docs/config/snapshotenvironment.md +0 -27
- package/vendor/vitest-docs/config/snapshotformat.md +0 -28
- package/vendor/vitest-docs/config/snapshotserializers.md +0 -6
- package/vendor/vitest-docs/config/stricttags.md +0 -30
- package/vendor/vitest-docs/config/tags.md +0 -141
- package/vendor/vitest-docs/config/teardowntimeout.md +0 -7
- package/vendor/vitest-docs/config/testnamepattern.md +0 -21
- package/vendor/vitest-docs/config/testtimeout.md +0 -7
- package/vendor/vitest-docs/config/typecheck.md +0 -77
- package/vendor/vitest-docs/config/ui.md +0 -15
- package/vendor/vitest-docs/config/unstubenvs.md +0 -20
- package/vendor/vitest-docs/config/unstubglobals.md +0 -20
- package/vendor/vitest-docs/config/update.md +0 -16
- package/vendor/vitest-docs/config/vmmemorylimit.md +0 -30
- package/vendor/vitest-docs/config/watch.md +0 -11
- package/vendor/vitest-docs/config/watchtriggerpatterns.md +0 -29
- package/vendor/vitest-docs/guide/advanced/index.md +0 -147
- package/vendor/vitest-docs/guide/advanced/pool.md +0 -148
- package/vendor/vitest-docs/guide/advanced/reporters.md +0 -93
- package/vendor/vitest-docs/guide/advanced/tests.md +0 -125
- package/vendor/vitest-docs/guide/browser/aria-snapshots.md +0 -470
- package/vendor/vitest-docs/guide/browser/component-testing.md +0 -571
- package/vendor/vitest-docs/guide/browser/index.md +0 -630
- package/vendor/vitest-docs/guide/browser/multiple-setups.md +0 -121
- package/vendor/vitest-docs/guide/browser/trace-view.md +0 -126
- package/vendor/vitest-docs/guide/browser/visual-regression-testing.md +0 -734
- package/vendor/vitest-docs/guide/cli-generated.md +0 -972
- package/vendor/vitest-docs/guide/cli.md +0 -234
- package/vendor/vitest-docs/guide/common-errors.md +0 -163
- package/vendor/vitest-docs/guide/coverage.md +0 -515
- package/vendor/vitest-docs/guide/debugging.md +0 -127
- package/vendor/vitest-docs/guide/environment.md +0 -101
- package/vendor/vitest-docs/guide/extending-matchers.md +0 -160
- package/vendor/vitest-docs/guide/features.md +0 -310
- package/vendor/vitest-docs/guide/filtering.md +0 -175
- package/vendor/vitest-docs/guide/ide.md +0 -43
- package/vendor/vitest-docs/guide/improving-performance.md +0 -245
- package/vendor/vitest-docs/guide/in-source.md +0 -159
- package/vendor/vitest-docs/guide/index.md +0 -128
- package/vendor/vitest-docs/guide/learn/async.md +0 -147
- package/vendor/vitest-docs/guide/learn/debugging-tests.md +0 -210
- package/vendor/vitest-docs/guide/learn/matchers.md +0 -277
- package/vendor/vitest-docs/guide/learn/mock-functions.md +0 -277
- package/vendor/vitest-docs/guide/learn/setup-teardown.md +0 -240
- package/vendor/vitest-docs/guide/learn/snapshots.md +0 -166
- package/vendor/vitest-docs/guide/learn/testing-in-practice.md +0 -430
- package/vendor/vitest-docs/guide/learn/writing-tests-with-ai.md +0 -127
- package/vendor/vitest-docs/guide/learn/writing-tests.md +0 -231
- package/vendor/vitest-docs/guide/lifecycle.md +0 -379
- package/vendor/vitest-docs/guide/migration.md +0 -863
- package/vendor/vitest-docs/guide/mocking/classes.md +0 -158
- package/vendor/vitest-docs/guide/mocking/dates.md +0 -52
- package/vendor/vitest-docs/guide/mocking/file-system.md +0 -74
- package/vendor/vitest-docs/guide/mocking/functions.md +0 -61
- package/vendor/vitest-docs/guide/mocking/globals.md +0 -20
- package/vendor/vitest-docs/guide/mocking/modules.md +0 -414
- package/vendor/vitest-docs/guide/mocking/requests.md +0 -114
- package/vendor/vitest-docs/guide/mocking/timers.md +0 -48
- package/vendor/vitest-docs/guide/mocking.md +0 -239
- package/vendor/vitest-docs/guide/open-telemetry.md +0 -156
- package/vendor/vitest-docs/guide/parallelism.md +0 -82
- package/vendor/vitest-docs/guide/profiling-test-performance.md +0 -243
- package/vendor/vitest-docs/guide/projects.md +0 -291
- package/vendor/vitest-docs/guide/recipes.md +0 -59
- package/vendor/vitest-docs/guide/reporters.md +0 -723
- package/vendor/vitest-docs/guide/snapshot.md +0 -620
- package/vendor/vitest-docs/guide/test-annotations.md +0 -103
- package/vendor/vitest-docs/guide/test-context.md +0 -902
- package/vendor/vitest-docs/guide/test-tags.md +0 -314
- package/vendor/vitest-docs/guide/testing-types.md +0 -149
- package/vendor/vitest-docs/guide/ui.md +0 -160
- package/vendor/vitest-docs/guide/using-plugins.md +0 -5
- package/vendor/vitest-docs/manifest.json +0 -1691
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# diff
|
|
2
|
-
|
|
3
|
-
- **Type:** `string`
|
|
4
|
-
- **CLI:** `--diff=<path>`
|
|
5
|
-
|
|
6
|
-
`DiffOptions` object or a path to a module which exports `DiffOptions`. Useful if you want to customize diff display.
|
|
7
|
-
|
|
8
|
-
Vitest diff rendering uses [`@vitest/pretty-format`](https://npmx.dev/package/@vitest/pretty-format) under the hood and a part of `DiffOptions` is forwarded to the pretty-format configuration, while the rest affects diff rendering itself.
|
|
9
|
-
|
|
10
|
-
For example, as a config object:
|
|
11
|
-
|
|
12
|
-
```ts
|
|
13
|
-
import { defineConfig } from 'vitest/config'
|
|
14
|
-
import c from 'picocolors'
|
|
15
|
-
|
|
16
|
-
export default defineConfig({
|
|
17
|
-
test: {
|
|
18
|
-
diff: {
|
|
19
|
-
aIndicator: c.bold('--'),
|
|
20
|
-
bIndicator: c.bold('++'),
|
|
21
|
-
omitAnnotationLines: true,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
})
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Or as a module:
|
|
28
|
-
|
|
29
|
-
:::code-group
|
|
30
|
-
```ts [vitest.config.js]
|
|
31
|
-
import { defineConfig } from 'vitest/config'
|
|
32
|
-
|
|
33
|
-
export default defineConfig({
|
|
34
|
-
test: {
|
|
35
|
-
diff: './vitest.diff.ts',
|
|
36
|
-
},
|
|
37
|
-
})
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
```ts [vitest.diff.ts]
|
|
41
|
-
import type { DiffOptions } from 'vitest'
|
|
42
|
-
import c from 'picocolors'
|
|
43
|
-
|
|
44
|
-
export default {
|
|
45
|
-
aIndicator: c.bold('--'),
|
|
46
|
-
bIndicator: c.bold('++'),
|
|
47
|
-
omitAnnotationLines: true,
|
|
48
|
-
} satisfies DiffOptions
|
|
49
|
-
```
|
|
50
|
-
:::
|
|
51
|
-
|
|
52
|
-
## diff.expand
|
|
53
|
-
|
|
54
|
-
- **Type:** `boolean`
|
|
55
|
-
- **Default:** `true`
|
|
56
|
-
- **CLI:** `--diff.expand=false`
|
|
57
|
-
|
|
58
|
-
Expand all common lines.
|
|
59
|
-
|
|
60
|
-
## diff.truncateThreshold
|
|
61
|
-
|
|
62
|
-
- **Type:** `number`
|
|
63
|
-
- **Default:** `0`
|
|
64
|
-
- **CLI:** `--diff.truncateThreshold=<path>`
|
|
65
|
-
|
|
66
|
-
The maximum length of diff result to be displayed. Diffs above this threshold will be truncated.
|
|
67
|
-
Truncation won't take effect with default value 0.
|
|
68
|
-
|
|
69
|
-
## diff.truncateAnnotation
|
|
70
|
-
|
|
71
|
-
- **Type:** `string`
|
|
72
|
-
- **Default:** `'... Diff result is truncated'`
|
|
73
|
-
- **CLI:** `--diff.truncateAnnotation=<annotation>`
|
|
74
|
-
|
|
75
|
-
Annotation that is output at the end of diff result if it's truncated.
|
|
76
|
-
|
|
77
|
-
## diff.truncateAnnotationColor
|
|
78
|
-
|
|
79
|
-
- **Type:** `DiffOptionsColor = (arg: string) => string`
|
|
80
|
-
- **Default:** `noColor = (string: string): string => string`
|
|
81
|
-
|
|
82
|
-
Color of truncate annotation, default is output with no color.
|
|
83
|
-
|
|
84
|
-
## diff.printBasicPrototype
|
|
85
|
-
|
|
86
|
-
- **Type:** `boolean`
|
|
87
|
-
- **Default:** `false`
|
|
88
|
-
|
|
89
|
-
Print basic prototype `Object` and `Array` in diff output.
|
|
90
|
-
|
|
91
|
-
## diff.maxDepth
|
|
92
|
-
|
|
93
|
-
- **Type:** `number`
|
|
94
|
-
- **Default:** `20` (or `8` when comparing different types)
|
|
95
|
-
|
|
96
|
-
Limit the depth to recurse when printing nested objects.
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# disableConsoleIntercept
|
|
2
|
-
|
|
3
|
-
- **Type:** `boolean`
|
|
4
|
-
- **CLI:** `--disableConsoleIntercept`
|
|
5
|
-
- **Default:** `false`
|
|
6
|
-
|
|
7
|
-
By default, Vitest automatically intercepts console logging during tests for extra formatting of test file, test title, etc.
|
|
8
|
-
|
|
9
|
-
This is also required for console log preview on Vitest UI.
|
|
10
|
-
|
|
11
|
-
However, disabling such interception might help when you want to debug a code with normal synchronous terminal console logging.
|
|
12
|
-
|
|
13
|
-
::: warning
|
|
14
|
-
This option has no effect on [browser tests](/guide/browser/) since Vitest preserves original logging in browser devtools.
|
|
15
|
-
:::
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# environment
|
|
2
|
-
|
|
3
|
-
- **Type:** `'node' | 'jsdom' | 'happy-dom' | 'edge-runtime' | string`
|
|
4
|
-
- **Default:** `'node'`
|
|
5
|
-
- **CLI:** `--environment=<env>`
|
|
6
|
-
|
|
7
|
-
The environment that will be used for testing. The default environment in Vitest
|
|
8
|
-
is a Node.js environment. If you are building a web application, you can use
|
|
9
|
-
browser-like environment through either [`jsdom`](https://github.com/jsdom/jsdom)
|
|
10
|
-
or [`happy-dom`](https://github.com/capricorn86/happy-dom) instead.
|
|
11
|
-
If you are building edge functions, you can use [`edge-runtime`](https://edge-runtime.vercel.app/packages/vm) environment
|
|
12
|
-
|
|
13
|
-
::: tip
|
|
14
|
-
You can also use [Browser Mode](/guide/browser/) to run integration or unit tests in the browser without mocking the environment.
|
|
15
|
-
:::
|
|
16
|
-
|
|
17
|
-
To define custom options for your environment, use [`environmentOptions`](/config/environmentoptions).
|
|
18
|
-
|
|
19
|
-
By adding a `@vitest-environment` docblock or comment at the top of the file,
|
|
20
|
-
you can specify another environment to be used for all tests in that file:
|
|
21
|
-
|
|
22
|
-
Docblock style:
|
|
23
|
-
|
|
24
|
-
```js
|
|
25
|
-
/**
|
|
26
|
-
* @vitest-environment jsdom
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
test('use jsdom in this test file', () => {
|
|
30
|
-
const element = document.createElement('div')
|
|
31
|
-
expect(element).not.toBeNull()
|
|
32
|
-
})
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Comment style:
|
|
36
|
-
|
|
37
|
-
```js
|
|
38
|
-
// @vitest-environment happy-dom
|
|
39
|
-
|
|
40
|
-
test('use happy-dom in this test file', () => {
|
|
41
|
-
const element = document.createElement('div')
|
|
42
|
-
expect(element).not.toBeNull()
|
|
43
|
-
})
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
For compatibility with Jest, there is also a `@jest-environment`:
|
|
47
|
-
|
|
48
|
-
```js
|
|
49
|
-
/**
|
|
50
|
-
* @jest-environment jsdom
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
test('use jsdom in this test file', () => {
|
|
54
|
-
const element = document.createElement('div')
|
|
55
|
-
expect(element).not.toBeNull()
|
|
56
|
-
})
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
You can also define a custom environment. When non-builtin environment is used, Vitest will try to load the file if it's relative or absolute, or a package `vitest-environment-${name}`, if the name is a bare specifier.
|
|
60
|
-
|
|
61
|
-
The custom environment file should export an object with the shape of `Environment`:
|
|
62
|
-
|
|
63
|
-
```ts [environment.js]
|
|
64
|
-
import type { Environment } from 'vitest'
|
|
65
|
-
|
|
66
|
-
export default <Environment>{
|
|
67
|
-
name: 'custom',
|
|
68
|
-
viteEnvironment: 'ssr',
|
|
69
|
-
setup() {
|
|
70
|
-
// custom setup
|
|
71
|
-
return {
|
|
72
|
-
teardown() {
|
|
73
|
-
// called after all tests with this env have been run
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
::: tip
|
|
81
|
-
The `viteEnvironment` field corresponds to the environment defined by the [Vite Environment API](https://vite.dev/guide/api-environment#environment-api). By default, Vite exposes `client` (for the browser) and `ssr` (for the server) environments.
|
|
82
|
-
:::
|
|
83
|
-
|
|
84
|
-
Vitest also exposes `builtinEnvironments` through `vitest/environments` entry, in case you just want to extend it. You can read more about extending environments in [our guide](/guide/environment).
|
|
85
|
-
|
|
86
|
-
::: tip
|
|
87
|
-
jsdom environment exposes `jsdom` global variable equal to the current [JSDOM](https://github.com/jsdom/jsdom) instance. If you want TypeScript to recognize it, you can add `vitest/jsdom` to your `tsconfig.json` when you use this environment:
|
|
88
|
-
|
|
89
|
-
```json [tsconfig.json]
|
|
90
|
-
{
|
|
91
|
-
"compilerOptions": {
|
|
92
|
-
"types": ["vitest/jsdom"]
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
```
|
|
96
|
-
:::
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# environmentOptions
|
|
2
|
-
|
|
3
|
-
- **Type:** `Record<'jsdom' | 'happyDOM' | string, unknown>`
|
|
4
|
-
- **Default:** `{}`
|
|
5
|
-
|
|
6
|
-
These options are passed to the setup method of the current [environment](/config/environment). By default, you can configure options only for `jsdom` and `happyDOM` when you use them as your test environment.
|
|
7
|
-
|
|
8
|
-
## Example
|
|
9
|
-
|
|
10
|
-
```js [vitest.config.js]
|
|
11
|
-
import { defineConfig } from 'vitest/config'
|
|
12
|
-
|
|
13
|
-
export default defineConfig({
|
|
14
|
-
test: {
|
|
15
|
-
environmentOptions: {
|
|
16
|
-
jsdom: {
|
|
17
|
-
url: 'http://localhost:3000',
|
|
18
|
-
},
|
|
19
|
-
happyDOM: {
|
|
20
|
-
width: 300,
|
|
21
|
-
height: 400,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
})
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
::: warning
|
|
29
|
-
Options are scoped to their environment. For example, put jsdom options under the `jsdom` key and happy-dom options under the `happyDOM` key. This lets you mix multiple environments within the same project.
|
|
30
|
-
:::
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# exclude
|
|
2
|
-
|
|
3
|
-
- **Type:** `string[]`
|
|
4
|
-
- **Default:** `['**/node_modules/**', '**/.git/**']`
|
|
5
|
-
- **CLI:** `vitest --exclude "**/excluded-file" --exclude "*/other-files/*.js"`
|
|
6
|
-
|
|
7
|
-
A list of [glob patterns](https://superchupu.dev/tinyglobby/comparison) that should be excluded from your test files. These patterns are resolved relative to the [`root`](/config/root) ([`process.cwd()`](https://nodejs.org/api/process.html#processcwd) by default).
|
|
8
|
-
|
|
9
|
-
Vitest uses the [`tinyglobby`](https://npmx.dev/package/tinyglobby) package to resolve the globs.
|
|
10
|
-
|
|
11
|
-
::: warning
|
|
12
|
-
This option does not affect coverage. If you need to remove certain files from the coverage report, use [`coverage.exclude`](/config/coverage#exclude).
|
|
13
|
-
|
|
14
|
-
This is the only option that doesn't override your configuration if you provide it with a CLI flag. All glob patterns added via `--exclude` flag will be added to the config's `exclude`.
|
|
15
|
-
:::
|
|
16
|
-
|
|
17
|
-
## Example
|
|
18
|
-
|
|
19
|
-
```js
|
|
20
|
-
import { defineConfig } from 'vitest/config'
|
|
21
|
-
|
|
22
|
-
export default defineConfig({
|
|
23
|
-
test: {
|
|
24
|
-
exclude: [
|
|
25
|
-
'**/node_modules/**',
|
|
26
|
-
'**/dist/**',
|
|
27
|
-
'./temp/**',
|
|
28
|
-
],
|
|
29
|
-
},
|
|
30
|
-
})
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
::: tip
|
|
34
|
-
Although the CLI `exclude` option is additive, manually setting `exclude` in your config will replace the default value. To extend the default `exclude` patterns, use `configDefaults` from `vitest/config`:
|
|
35
|
-
|
|
36
|
-
```js{6}
|
|
37
|
-
import { configDefaults, defineConfig } from 'vitest/config'
|
|
38
|
-
|
|
39
|
-
export default defineConfig({
|
|
40
|
-
test: {
|
|
41
|
-
exclude: [
|
|
42
|
-
...configDefaults.exclude,
|
|
43
|
-
'packages/template/*',
|
|
44
|
-
'./temp/**',
|
|
45
|
-
],
|
|
46
|
-
},
|
|
47
|
-
})
|
|
48
|
-
```
|
|
49
|
-
:::
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# execArgv
|
|
2
|
-
|
|
3
|
-
- **Type:** `string[]`
|
|
4
|
-
- **Default:** `[]`
|
|
5
|
-
|
|
6
|
-
Pass additional arguments to `node` in the runner worker. See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
|
|
7
|
-
|
|
8
|
-
:::warning
|
|
9
|
-
Be careful when using, it as some options may crash worker, e.g. `--prof`, `--title`. See https://github.com/nodejs/node/issues/41103.
|
|
10
|
-
:::
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# expect
|
|
2
|
-
|
|
3
|
-
- **Type:** `ExpectOptions`
|
|
4
|
-
|
|
5
|
-
## expect.requireAssertions
|
|
6
|
-
|
|
7
|
-
- **Type:** `boolean`
|
|
8
|
-
- **Default:** `false`
|
|
9
|
-
|
|
10
|
-
The same as calling [`expect.hasAssertions()`](/api/expect#expect-hasassertions) at the start of every test. This makes sure that no test will pass accidentally.
|
|
11
|
-
|
|
12
|
-
::: tip
|
|
13
|
-
This only works with Vitest's `expect`. If you use `assert` or `.should` assertions, they will not count, and your test will fail due to the lack of expect assertions.
|
|
14
|
-
|
|
15
|
-
You can change the value of this by calling `vi.setConfig({ expect: { requireAssertions: false } })`. The config will be applied to every subsequent `expect` call until the `vi.resetConfig` is called manually.
|
|
16
|
-
:::
|
|
17
|
-
|
|
18
|
-
::: warning
|
|
19
|
-
When you run tests with `sequence.concurrent` and `expect.requireAssertions` set to `true`, you should use [local expect](/guide/test-context.html#expect) instead of the global one. Otherwise, this may cause false negatives in [some situations (#8469)](https://github.com/vitest-dev/vitest/issues/8469).
|
|
20
|
-
:::
|
|
21
|
-
|
|
22
|
-
## expect.poll
|
|
23
|
-
|
|
24
|
-
Global configuration options for [`expect.poll`](/api/expect#poll). These are the same options you can pass down to `expect.poll(condition, options)`.
|
|
25
|
-
|
|
26
|
-
### expect.poll.interval
|
|
27
|
-
|
|
28
|
-
- **Type:** `number`
|
|
29
|
-
- **Default:** `50`
|
|
30
|
-
|
|
31
|
-
Polling interval in milliseconds
|
|
32
|
-
|
|
33
|
-
### expect.poll.timeout
|
|
34
|
-
|
|
35
|
-
- **Type:** `number`
|
|
36
|
-
- **Default:** `1000`
|
|
37
|
-
|
|
38
|
-
Polling timeout in milliseconds
|