@vitest-agent/mcp 1.0.1 → 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/bin/vitest-agent-mcp.js +1 -17
- package/index.d.ts +324 -315
- package/index.js +2 -4
- package/middleware/idempotency.js +1 -1
- package/package.json +2 -2
- package/server.js +2 -4
- package/tools/acceptance-metrics.js +1 -1
- package/tools/cache-health.js +1 -1
- package/tools/commit-changes.js +1 -1
- package/tools/configure.js +1 -1
- package/tools/coverage.js +1 -1
- package/tools/errors.js +1 -1
- package/tools/failure-signature-get.js +1 -1
- package/tools/file-coverage.js +1 -1
- package/tools/history.js +1 -1
- package/tools/inventory.js +1 -1
- package/tools/overview.js +1 -1
- package/tools/run-tests.js +15 -3
- package/tools/settings-list.js +1 -1
- package/tools/status.js +1 -1
- package/tools/tdd-artifact.js +1 -1
- package/tools/tdd-task.js +1 -1
- package/tools/test.js +1 -1
- package/tools/trends.js +1 -1
- package/tools/turn-search.js +1 -1
- package/public/patterns/_meta.json +0 -67
- package/public/patterns/authoring-a-custom-vitest-agent-reporter.md +0 -82
- package/public/patterns/known-issues-and-caveats.md +0 -52
- package/public/patterns/operating-vitest-agent-as-an-agent.md +0 -53
- package/public/patterns/running-tests-via-mcp.md +0 -58
- package/public/patterns/silencing-leaking-output-in-tests.md +0 -91
- package/public/patterns/testing-effect-schema-definitions.md +0 -71
- package/public/patterns/testing-effect-services-with-mock-layers.md +0 -63
- package/public/vendor/vitest-docs/ATTRIBUTION.md +0 -5
- package/public/vendor/vitest-docs/api/advanced/artifacts.md +0 -189
- package/public/vendor/vitest-docs/api/advanced/metadata.md +0 -68
- package/public/vendor/vitest-docs/api/advanced/plugin.md +0 -168
- package/public/vendor/vitest-docs/api/advanced/reporters.md +0 -342
- package/public/vendor/vitest-docs/api/advanced/runner.md +0 -334
- package/public/vendor/vitest-docs/api/advanced/test-case.md +0 -302
- package/public/vendor/vitest-docs/api/advanced/test-collection.md +0 -89
- package/public/vendor/vitest-docs/api/advanced/test-module.md +0 -140
- package/public/vendor/vitest-docs/api/advanced/test-project.md +0 -321
- package/public/vendor/vitest-docs/api/advanced/test-specification.md +0 -96
- package/public/vendor/vitest-docs/api/advanced/test-suite.md +0 -230
- package/public/vendor/vitest-docs/api/advanced/vitest.md +0 -684
- package/public/vendor/vitest-docs/api/assert-type.md +0 -22
- package/public/vendor/vitest-docs/api/assert.md +0 -1960
- package/public/vendor/vitest-docs/api/browser/assertions.md +0 -1277
- package/public/vendor/vitest-docs/api/browser/commands.md +0 -154
- package/public/vendor/vitest-docs/api/browser/context.md +0 -338
- package/public/vendor/vitest-docs/api/browser/interactivity.md +0 -681
- package/public/vendor/vitest-docs/api/browser/locators.md +0 -1171
- package/public/vendor/vitest-docs/api/browser/react.md +0 -346
- package/public/vendor/vitest-docs/api/browser/svelte.md +0 -292
- package/public/vendor/vitest-docs/api/browser/vue.md +0 -222
- package/public/vendor/vitest-docs/api/describe.md +0 -374
- package/public/vendor/vitest-docs/api/expect-typeof.md +0 -571
- package/public/vendor/vitest-docs/api/expect.md +0 -2304
- package/public/vendor/vitest-docs/api/hooks.md +0 -463
- package/public/vendor/vitest-docs/api/mock.md +0 -701
- package/public/vendor/vitest-docs/api/test.md +0 -926
- package/public/vendor/vitest-docs/api/vi.md +0 -1372
- package/public/vendor/vitest-docs/config/alias.md +0 -13
- package/public/vendor/vitest-docs/config/allowonly.md +0 -32
- package/public/vendor/vitest-docs/config/api.md +0 -27
- package/public/vendor/vitest-docs/config/attachmentsdir.md +0 -6
- package/public/vendor/vitest-docs/config/bail.md +0 -9
- package/public/vendor/vitest-docs/config/benchmark.md +0 -65
- package/public/vendor/vitest-docs/config/browser/api.md +0 -23
- package/public/vendor/vitest-docs/config/browser/commands.md +0 -6
- package/public/vendor/vitest-docs/config/browser/connecttimeout.md +0 -10
- package/public/vendor/vitest-docs/config/browser/detailspanelposition.md +0 -38
- package/public/vendor/vitest-docs/config/browser/enabled.md +0 -40
- package/public/vendor/vitest-docs/config/browser/expect.md +0 -250
- package/public/vendor/vitest-docs/config/browser/headless.md +0 -7
- package/public/vendor/vitest-docs/config/browser/instances.md +0 -47
- package/public/vendor/vitest-docs/config/browser/isolate.md +0 -11
- package/public/vendor/vitest-docs/config/browser/locators.md +0 -24
- package/public/vendor/vitest-docs/config/browser/orchestratorscripts.md +0 -39
- package/public/vendor/vitest-docs/config/browser/playwright.md +0 -214
- package/public/vendor/vitest-docs/config/browser/preview.md +0 -32
- package/public/vendor/vitest-docs/config/browser/provider.md +0 -79
- package/public/vendor/vitest-docs/config/browser/screenshotdirectory.md +0 -6
- package/public/vendor/vitest-docs/config/browser/screenshotfailures.md +0 -6
- package/public/vendor/vitest-docs/config/browser/testerhtmlpath.md +0 -5
- package/public/vendor/vitest-docs/config/browser/trace.md +0 -43
- package/public/vendor/vitest-docs/config/browser/trackunhandlederrors.md +0 -10
- package/public/vendor/vitest-docs/config/browser/ui.md +0 -7
- package/public/vendor/vitest-docs/config/browser/viewport.md +0 -6
- package/public/vendor/vitest-docs/config/browser/webdriverio.md +0 -64
- package/public/vendor/vitest-docs/config/cache.md +0 -26
- package/public/vendor/vitest-docs/config/chaiconfig.md +0 -29
- package/public/vendor/vitest-docs/config/clearmocks.md +0 -22
- package/public/vendor/vitest-docs/config/coverage.md +0 -455
- package/public/vendor/vitest-docs/config/css.md +0 -47
- package/public/vendor/vitest-docs/config/dangerouslyignoreunhandlederrors.md +0 -23
- package/public/vendor/vitest-docs/config/deps.md +0 -127
- package/public/vendor/vitest-docs/config/detectasyncleaks.md +0 -39
- package/public/vendor/vitest-docs/config/diff.md +0 -96
- package/public/vendor/vitest-docs/config/dir.md +0 -7
- package/public/vendor/vitest-docs/config/disableconsoleintercept.md +0 -15
- package/public/vendor/vitest-docs/config/env.md +0 -5
- package/public/vendor/vitest-docs/config/environment.md +0 -96
- package/public/vendor/vitest-docs/config/environmentoptions.md +0 -30
- package/public/vendor/vitest-docs/config/exclude.md +0 -49
- package/public/vendor/vitest-docs/config/execargv.md +0 -10
- package/public/vendor/vitest-docs/config/expandsnapshotdiff.md +0 -7
- package/public/vendor/vitest-docs/config/expect.md +0 -38
- package/public/vendor/vitest-docs/config/experimental.md +0 -510
- package/public/vendor/vitest-docs/config/faketimers.md +0 -51
- package/public/vendor/vitest-docs/config/fileparallelism.md +0 -11
- package/public/vendor/vitest-docs/config/forcereruntriggers.md +0 -19
- package/public/vendor/vitest-docs/config/globals.md +0 -42
- package/public/vendor/vitest-docs/config/globalsetup.md +0 -72
- package/public/vendor/vitest-docs/config/hideskippedtests.md +0 -7
- package/public/vendor/vitest-docs/config/hooktimeout.md +0 -7
- package/public/vendor/vitest-docs/config/include-source.md +0 -115
- package/public/vendor/vitest-docs/config/include.md +0 -71
- package/public/vendor/vitest-docs/config/includetasklocation.md +0 -17
- package/public/vendor/vitest-docs/config/index.md +0 -85
- package/public/vendor/vitest-docs/config/isolate.md +0 -13
- package/public/vendor/vitest-docs/config/logheapusage.md +0 -7
- package/public/vendor/vitest-docs/config/maxconcurrency.md +0 -9
- package/public/vendor/vitest-docs/config/maxworkers.md +0 -49
- package/public/vendor/vitest-docs/config/mockreset.md +0 -22
- package/public/vendor/vitest-docs/config/mode.md +0 -7
- package/public/vendor/vitest-docs/config/name.md +0 -111
- package/public/vendor/vitest-docs/config/onconsolelog.md +0 -25
- package/public/vendor/vitest-docs/config/onstacktrace.md +0 -32
- package/public/vendor/vitest-docs/config/onunhandlederror.md +0 -35
- package/public/vendor/vitest-docs/config/open.md +0 -7
- package/public/vendor/vitest-docs/config/outputfile.md +0 -7
- package/public/vendor/vitest-docs/config/passwithnotests.md +0 -7
- package/public/vendor/vitest-docs/config/pool.md +0 -45
- package/public/vendor/vitest-docs/config/printconsoletrace.md +0 -6
- package/public/vendor/vitest-docs/config/projects.md +0 -6
- package/public/vendor/vitest-docs/config/provide.md +0 -45
- package/public/vendor/vitest-docs/config/reporters.md +0 -69
- package/public/vendor/vitest-docs/config/resolvesnapshotpath.md +0 -36
- package/public/vendor/vitest-docs/config/restoremocks.md +0 -22
- package/public/vendor/vitest-docs/config/retry.md +0 -140
- package/public/vendor/vitest-docs/config/root.md +0 -6
- package/public/vendor/vitest-docs/config/runner.md +0 -6
- package/public/vendor/vitest-docs/config/sequence.md +0 -158
- package/public/vendor/vitest-docs/config/server.md +0 -68
- package/public/vendor/vitest-docs/config/setupfiles.md +0 -40
- package/public/vendor/vitest-docs/config/silent.md +0 -9
- package/public/vendor/vitest-docs/config/slowtestthreshold.md +0 -7
- package/public/vendor/vitest-docs/config/snapshotenvironment.md +0 -27
- package/public/vendor/vitest-docs/config/snapshotformat.md +0 -28
- package/public/vendor/vitest-docs/config/snapshotserializers.md +0 -6
- package/public/vendor/vitest-docs/config/stricttags.md +0 -30
- package/public/vendor/vitest-docs/config/tags.md +0 -141
- package/public/vendor/vitest-docs/config/teardowntimeout.md +0 -7
- package/public/vendor/vitest-docs/config/testnamepattern.md +0 -21
- package/public/vendor/vitest-docs/config/testtimeout.md +0 -7
- package/public/vendor/vitest-docs/config/typecheck.md +0 -77
- package/public/vendor/vitest-docs/config/ui.md +0 -15
- package/public/vendor/vitest-docs/config/unstubenvs.md +0 -20
- package/public/vendor/vitest-docs/config/unstubglobals.md +0 -20
- package/public/vendor/vitest-docs/config/update.md +0 -16
- package/public/vendor/vitest-docs/config/vmmemorylimit.md +0 -30
- package/public/vendor/vitest-docs/config/watch.md +0 -11
- package/public/vendor/vitest-docs/config/watchtriggerpatterns.md +0 -29
- package/public/vendor/vitest-docs/guide/advanced/index.md +0 -147
- package/public/vendor/vitest-docs/guide/advanced/pool.md +0 -148
- package/public/vendor/vitest-docs/guide/advanced/reporters.md +0 -93
- package/public/vendor/vitest-docs/guide/advanced/tests.md +0 -125
- package/public/vendor/vitest-docs/guide/browser/aria-snapshots.md +0 -470
- package/public/vendor/vitest-docs/guide/browser/component-testing.md +0 -571
- package/public/vendor/vitest-docs/guide/browser/index.md +0 -630
- package/public/vendor/vitest-docs/guide/browser/multiple-setups.md +0 -121
- package/public/vendor/vitest-docs/guide/browser/trace-view.md +0 -126
- package/public/vendor/vitest-docs/guide/browser/visual-regression-testing.md +0 -734
- package/public/vendor/vitest-docs/guide/cli-generated.md +0 -972
- package/public/vendor/vitest-docs/guide/cli.md +0 -234
- package/public/vendor/vitest-docs/guide/common-errors.md +0 -163
- package/public/vendor/vitest-docs/guide/coverage.md +0 -515
- package/public/vendor/vitest-docs/guide/debugging.md +0 -127
- package/public/vendor/vitest-docs/guide/environment.md +0 -101
- package/public/vendor/vitest-docs/guide/extending-matchers.md +0 -160
- package/public/vendor/vitest-docs/guide/features.md +0 -310
- package/public/vendor/vitest-docs/guide/filtering.md +0 -175
- package/public/vendor/vitest-docs/guide/ide.md +0 -43
- package/public/vendor/vitest-docs/guide/improving-performance.md +0 -245
- package/public/vendor/vitest-docs/guide/in-source.md +0 -159
- package/public/vendor/vitest-docs/guide/index.md +0 -128
- package/public/vendor/vitest-docs/guide/learn/async.md +0 -147
- package/public/vendor/vitest-docs/guide/learn/debugging-tests.md +0 -210
- package/public/vendor/vitest-docs/guide/learn/matchers.md +0 -277
- package/public/vendor/vitest-docs/guide/learn/mock-functions.md +0 -277
- package/public/vendor/vitest-docs/guide/learn/setup-teardown.md +0 -240
- package/public/vendor/vitest-docs/guide/learn/snapshots.md +0 -166
- package/public/vendor/vitest-docs/guide/learn/testing-in-practice.md +0 -430
- package/public/vendor/vitest-docs/guide/learn/writing-tests-with-ai.md +0 -127
- package/public/vendor/vitest-docs/guide/learn/writing-tests.md +0 -231
- package/public/vendor/vitest-docs/guide/lifecycle.md +0 -379
- package/public/vendor/vitest-docs/guide/migration.md +0 -863
- package/public/vendor/vitest-docs/guide/mocking/classes.md +0 -158
- package/public/vendor/vitest-docs/guide/mocking/dates.md +0 -52
- package/public/vendor/vitest-docs/guide/mocking/file-system.md +0 -74
- package/public/vendor/vitest-docs/guide/mocking/functions.md +0 -61
- package/public/vendor/vitest-docs/guide/mocking/globals.md +0 -20
- package/public/vendor/vitest-docs/guide/mocking/modules.md +0 -414
- package/public/vendor/vitest-docs/guide/mocking/requests.md +0 -114
- package/public/vendor/vitest-docs/guide/mocking/timers.md +0 -48
- package/public/vendor/vitest-docs/guide/mocking.md +0 -239
- package/public/vendor/vitest-docs/guide/open-telemetry.md +0 -156
- package/public/vendor/vitest-docs/guide/parallelism.md +0 -82
- package/public/vendor/vitest-docs/guide/profiling-test-performance.md +0 -243
- package/public/vendor/vitest-docs/guide/projects.md +0 -291
- package/public/vendor/vitest-docs/guide/recipes.md +0 -59
- package/public/vendor/vitest-docs/guide/reporters.md +0 -723
- package/public/vendor/vitest-docs/guide/snapshot.md +0 -620
- package/public/vendor/vitest-docs/guide/test-annotations.md +0 -103
- package/public/vendor/vitest-docs/guide/test-context.md +0 -902
- package/public/vendor/vitest-docs/guide/test-tags.md +0 -314
- package/public/vendor/vitest-docs/guide/testing-types.md +0 -149
- package/public/vendor/vitest-docs/guide/ui.md +0 -160
- package/public/vendor/vitest-docs/guide/using-plugins.md +0 -5
- package/public/vendor/vitest-docs/manifest.json +0 -1691
- 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
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# onUnhandledError <CRoot /> <Version>4.0.0</Version>
|
|
2
|
-
|
|
3
|
-
- **Type:**
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
function onUnhandledError(
|
|
7
|
-
error: (TestError | Error) & { type: string }
|
|
8
|
-
): boolean | void
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
A custom callback for filtering unhandled errors that should not be reported. When an error is filtered out, it no longer affects the result of the test run.
|
|
12
|
-
|
|
13
|
-
To report unhandled errors without affecting the test outcome, use the [`dangerouslyIgnoreUnhandledErrors`](/config/dangerouslyignoreunhandlederrors) option instead.
|
|
14
|
-
|
|
15
|
-
::: tip
|
|
16
|
-
This callback is called on the main thread, it doesn't have access to your test context.
|
|
17
|
-
:::
|
|
18
|
-
|
|
19
|
-
## Example
|
|
20
|
-
|
|
21
|
-
```ts
|
|
22
|
-
import type { ParsedStack } from 'vitest'
|
|
23
|
-
import { defineConfig } from 'vitest/config'
|
|
24
|
-
|
|
25
|
-
export default defineConfig({
|
|
26
|
-
test: {
|
|
27
|
-
onUnhandledError(error): boolean | void {
|
|
28
|
-
// Ignore all errors with the name "MySpecialError".
|
|
29
|
-
if (error.name === 'MySpecialError') {
|
|
30
|
-
return false
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
})
|
|
35
|
-
```
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# outputFile <CRoot /> {#outputfile}
|
|
2
|
-
|
|
3
|
-
- **Type:** `string | Record<string, string>`
|
|
4
|
-
- **CLI:** `--outputFile=<path>`, `--outputFile.json=./path`
|
|
5
|
-
|
|
6
|
-
Write test results to a file when the `--reporter=json`, `--reporter=html` or `--reporter=junit` option is also specified.
|
|
7
|
-
By providing an object instead of a string you can define individual outputs when using multiple reporters.
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# pool
|
|
2
|
-
|
|
3
|
-
- **Type:** `'threads' | 'forks' | 'vmThreads' | 'vmForks'`
|
|
4
|
-
- **Default:** `'forks'`
|
|
5
|
-
- **CLI:** `--pool=threads`
|
|
6
|
-
|
|
7
|
-
Pool used to run tests in.
|
|
8
|
-
|
|
9
|
-
## threads
|
|
10
|
-
|
|
11
|
-
Enable multi-threading. When using threads you are unable to use process related APIs such as `process.chdir()`. Some libraries written in native languages, such as `Prisma`, `bcrypt` and `canvas`, have problems when running in multiple threads and run into segfaults. In these cases it is advised to use `forks` pool instead.
|
|
12
|
-
|
|
13
|
-
## forks
|
|
14
|
-
|
|
15
|
-
Similar as `threads` pool but uses `child_process` instead of `worker_threads`. Communication between tests and main process is not as fast as with `threads` pool. Process related APIs such as `process.chdir()` are available in `forks` pool.
|
|
16
|
-
|
|
17
|
-
## vmThreads
|
|
18
|
-
|
|
19
|
-
Run tests using [VM context](https://nodejs.org/api/vm.html) (inside a sandboxed environment) in a `threads` pool.
|
|
20
|
-
|
|
21
|
-
This makes tests run faster, but the VM module is unstable when running [ESM code](https://github.com/nodejs/node/issues/37648). Your tests will [leak memory](https://github.com/nodejs/node/issues/33439) - to battle that, consider manually editing [`vmMemoryLimit`](/config/vmmemorylimit) value.
|
|
22
|
-
|
|
23
|
-
::: warning
|
|
24
|
-
Running code in a sandbox has some advantages (faster tests), but also comes with a number of disadvantages.
|
|
25
|
-
|
|
26
|
-
- The globals within native modules, such as (`fs`, `path`, etc), differ from the globals present in your test environment. As a result, any error thrown by these native modules will reference a different Error constructor compared to the one used in your code:
|
|
27
|
-
|
|
28
|
-
```ts
|
|
29
|
-
try {
|
|
30
|
-
fs.writeFileSync('/does-not-exist')
|
|
31
|
-
}
|
|
32
|
-
catch (err) {
|
|
33
|
-
console.log(err instanceof Error) // false
|
|
34
|
-
}
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
- Importing ES modules caches them indefinitely which introduces memory leaks if you have a lot of contexts (test files). There is no API in Node.js that clears that cache.
|
|
38
|
-
- Accessing globals [takes longer](https://github.com/nodejs/node/issues/31658) in a sandbox environment.
|
|
39
|
-
|
|
40
|
-
Please, be aware of these issues when using this option. Vitest team cannot fix any of the issues on our side.
|
|
41
|
-
:::
|
|
42
|
-
|
|
43
|
-
## vmForks
|
|
44
|
-
|
|
45
|
-
Similar as `vmThreads` pool but uses `child_process` instead of `worker_threads`. Communication between tests and the main process is not as fast as with `vmThreads` pool. Process related APIs such as `process.chdir()` are available in `vmForks` pool. Please be aware that this pool has the same pitfalls listed in `vmThreads`.
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# provide
|
|
2
|
-
|
|
3
|
-
- **Type:** `Partial<ProvidedContext>`
|
|
4
|
-
|
|
5
|
-
Define values that can be accessed inside your tests using `inject` method.
|
|
6
|
-
|
|
7
|
-
:::code-group
|
|
8
|
-
```ts [vitest.config.js]
|
|
9
|
-
import { defineConfig } from 'vitest/config'
|
|
10
|
-
|
|
11
|
-
export default defineConfig({
|
|
12
|
-
test: {
|
|
13
|
-
provide: {
|
|
14
|
-
API_KEY: '123',
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
})
|
|
18
|
-
```
|
|
19
|
-
```ts [api.test.js]
|
|
20
|
-
import { expect, inject, test } from 'vitest'
|
|
21
|
-
|
|
22
|
-
test('api key is defined', () => {
|
|
23
|
-
expect(inject('API_KEY')).toBe('123')
|
|
24
|
-
})
|
|
25
|
-
```
|
|
26
|
-
:::
|
|
27
|
-
|
|
28
|
-
::: warning
|
|
29
|
-
Properties have to be strings and values need to be [serializable](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types) because this object will be transferred between different processes.
|
|
30
|
-
:::
|
|
31
|
-
|
|
32
|
-
::: tip
|
|
33
|
-
If you are using TypeScript, you will need to augment `ProvidedContext` type for type safe access:
|
|
34
|
-
|
|
35
|
-
```ts [vitest.shims.d.ts]
|
|
36
|
-
declare module 'vitest' {
|
|
37
|
-
export interface ProvidedContext {
|
|
38
|
-
API_KEY: string
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// mark this file as a module so augmentation works correctly
|
|
43
|
-
export {}
|
|
44
|
-
```
|
|
45
|
-
:::
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
# reporters <CRoot />
|
|
2
|
-
|
|
3
|
-
- **Type:**
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
interface UserConfig {
|
|
7
|
-
reporters?: ConfigReporter | Array<ConfigReporter>
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
type ConfigReporter = string | Reporter | [string, object?]
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
- **Default:** [`'default'`](/guide/reporters#default-reporter) (or <code>[['default'](/guide/reporters#default-reporter), ['github-actions'](/guide/reporters#github-actions-reporter)]</code> when `process.env.GITHUB_ACTIONS === 'true'`)
|
|
14
|
-
- **CLI:**
|
|
15
|
-
- `--reporter=tap` for a single reporter
|
|
16
|
-
- `--reporter=verbose --reporter=github-actions` for multiple reporters
|
|
17
|
-
|
|
18
|
-
This option defines a single reporter or a list of reporters available to Vitest during the test run.
|
|
19
|
-
|
|
20
|
-
Alongside built-in reporters, you can also pass down a custom implementation of a [`Reporter` interface](/api/advanced/reporters), or a path to a module that exports it as a default export (e.g. `'./path/to/reporter.ts'`, `'@scope/reporter'`).
|
|
21
|
-
|
|
22
|
-
You can configure a reporter by providing a tuple: `[string, object]`, where the string is a reporter name, and the object is the reporter's options.
|
|
23
|
-
|
|
24
|
-
::: warning
|
|
25
|
-
Note that the [coverage](/guide/coverage) feature uses a different [`coverage.reporter`](/config/coverage#reporter) option instead of this one.
|
|
26
|
-
:::
|
|
27
|
-
|
|
28
|
-
## Built-in Reporters
|
|
29
|
-
|
|
30
|
-
- [`default`](/guide/reporters#default-reporter)
|
|
31
|
-
- [`verbose`](/guide/reporters#verbose-reporter)
|
|
32
|
-
- [`tree`](/guide/reporters#tree-reporter)
|
|
33
|
-
- [`dot`](/guide/reporters#dot-reporter)
|
|
34
|
-
- [`junit`](/guide/reporters#junit-reporter)
|
|
35
|
-
- [`json`](/guide/reporters#json-reporter)
|
|
36
|
-
- [`html`](/guide/reporters#html-reporter)
|
|
37
|
-
- [`tap`](/guide/reporters#tap-reporter)
|
|
38
|
-
- [`tap-flat`](/guide/reporters#tap-flat-reporter)
|
|
39
|
-
- [`hanging-process`](/guide/reporters#hanging-process-reporter)
|
|
40
|
-
- [`github-actions`](/guide/reporters#github-actions-reporter)
|
|
41
|
-
- [`minimal`](/guide/reporters#minimal-reporter) (aliased as `agent`)
|
|
42
|
-
- [`blob`](/guide/reporters#blob-reporter)
|
|
43
|
-
|
|
44
|
-
## Example
|
|
45
|
-
|
|
46
|
-
::: code-group
|
|
47
|
-
```js [vitest.config.js]
|
|
48
|
-
import { defineConfig } from 'vitest/config'
|
|
49
|
-
|
|
50
|
-
export default defineConfig({
|
|
51
|
-
test: {
|
|
52
|
-
reporters: [
|
|
53
|
-
'default',
|
|
54
|
-
// conditional reporter
|
|
55
|
-
process.env.CI ? 'github-actions' : {},
|
|
56
|
-
// custom reporter from npm package
|
|
57
|
-
// options are passed down as a tuple
|
|
58
|
-
[
|
|
59
|
-
'vitest-sonar-reporter',
|
|
60
|
-
{ outputFile: 'sonar-report.xml' }
|
|
61
|
-
],
|
|
62
|
-
]
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
```
|
|
66
|
-
```bash [CLI]
|
|
67
|
-
vitest --reporter=github-actions --reporter=junit
|
|
68
|
-
```
|
|
69
|
-
:::
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# resolveSnapshotPath <CRoot />
|
|
2
|
-
|
|
3
|
-
- **Type:** `(testPath: string, snapExtension: string, context: { config: SerializedConfig }) => string`
|
|
4
|
-
- **Default:** stores snapshot files in `__snapshots__` directory
|
|
5
|
-
|
|
6
|
-
Overrides default snapshot path. For example, to store snapshots next to test files:
|
|
7
|
-
|
|
8
|
-
```ts
|
|
9
|
-
import { defineConfig } from 'vitest/config'
|
|
10
|
-
|
|
11
|
-
export default defineConfig({
|
|
12
|
-
test: {
|
|
13
|
-
resolveSnapshotPath: (testPath, snapExtension) => testPath + snapExtension,
|
|
14
|
-
},
|
|
15
|
-
})
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
You can also use the `context` parameter to access the project's serialized config. This is useful when you have multiple [projects](/guide/projects) and want to store snapshots in different locations based on the project name:
|
|
19
|
-
|
|
20
|
-
```ts
|
|
21
|
-
import { basename, dirname, join } from 'node:path'
|
|
22
|
-
import { defineConfig } from 'vitest/config'
|
|
23
|
-
|
|
24
|
-
export default defineConfig({
|
|
25
|
-
test: {
|
|
26
|
-
resolveSnapshotPath(testPath, snapExtension, context) {
|
|
27
|
-
return join(
|
|
28
|
-
dirname(testPath),
|
|
29
|
-
'__snapshots__',
|
|
30
|
-
context.config.name ?? 'default',
|
|
31
|
-
basename(testPath) + snapExtension,
|
|
32
|
-
)
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
})
|
|
36
|
-
```
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# restoreMocks
|
|
2
|
-
|
|
3
|
-
- **Type:** `boolean`
|
|
4
|
-
- **Default:** `false`
|
|
5
|
-
|
|
6
|
-
Should Vitest automatically call [`vi.restoreAllMocks()`](/api/vi#vi-restoreallmocks) before each test.
|
|
7
|
-
|
|
8
|
-
This restores all original implementations on spies created manually with [`vi.spyOn`](/api/vi#vi-spyon).
|
|
9
|
-
|
|
10
|
-
```js [vitest.config.js]
|
|
11
|
-
import { defineConfig } from 'vitest/config'
|
|
12
|
-
|
|
13
|
-
export default defineConfig({
|
|
14
|
-
test: {
|
|
15
|
-
restoreMocks: true,
|
|
16
|
-
},
|
|
17
|
-
})
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
::: warning
|
|
21
|
-
Be aware that this option may cause problems with async [concurrent tests](/api/test#test-concurrent). If enabled, the completion of one test will restore the implementation for all spies, including those currently being used by other tests in progress.
|
|
22
|
-
:::
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
# retry
|
|
2
|
-
|
|
3
|
-
Retry the test specific number of times if it fails.
|
|
4
|
-
|
|
5
|
-
- **Type:** `number | { count?: number, delay?: number, condition?: RegExp }`
|
|
6
|
-
- **Default:** `0`
|
|
7
|
-
- **CLI:** `--retry <times>`, `--retry.count <times>`, `--retry.delay <ms>`, `--retry.condition <pattern>`
|
|
8
|
-
|
|
9
|
-
## Basic Usage
|
|
10
|
-
|
|
11
|
-
Specify a number to retry failed tests:
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
export default defineConfig({
|
|
15
|
-
test: {
|
|
16
|
-
retry: 3,
|
|
17
|
-
},
|
|
18
|
-
})
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## CLI Usage
|
|
22
|
-
|
|
23
|
-
You can also configure retry options from the command line:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
# Simple retry count
|
|
27
|
-
vitest --retry 3
|
|
28
|
-
|
|
29
|
-
# Advanced options using dot notation
|
|
30
|
-
vitest --retry.count 3 --retry.delay 500 --retry.condition 'ECONNREFUSED|timeout'
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## Advanced Options <Version>4.1.0</Version> {#advanced-options}
|
|
34
|
-
|
|
35
|
-
Use an object to configure retry behavior:
|
|
36
|
-
|
|
37
|
-
```ts
|
|
38
|
-
export default defineConfig({
|
|
39
|
-
test: {
|
|
40
|
-
retry: {
|
|
41
|
-
count: 3, // Number of times to retry
|
|
42
|
-
delay: 1000, // Delay in milliseconds between retries
|
|
43
|
-
condition: /ECONNREFUSED|timeout/i, // RegExp to match errors that should trigger retry
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
})
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### count
|
|
50
|
-
|
|
51
|
-
Number of times to retry a test if it fails. Default is `0`.
|
|
52
|
-
|
|
53
|
-
```ts
|
|
54
|
-
export default defineConfig({
|
|
55
|
-
test: {
|
|
56
|
-
retry: {
|
|
57
|
-
count: 2,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
})
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### delay
|
|
64
|
-
|
|
65
|
-
Delay in milliseconds between retry attempts. Useful for tests that interact with rate-limited APIs or need time to recover. Default is `0`.
|
|
66
|
-
|
|
67
|
-
```ts
|
|
68
|
-
export default defineConfig({
|
|
69
|
-
test: {
|
|
70
|
-
retry: {
|
|
71
|
-
count: 3,
|
|
72
|
-
delay: 500, // Wait 500ms between retries
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
})
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### condition
|
|
79
|
-
|
|
80
|
-
A RegExp pattern or a function to determine if a test should be retried based on the error.
|
|
81
|
-
|
|
82
|
-
- When a **RegExp**, it's tested against the error message
|
|
83
|
-
- When a **function**, it receives the error and returns a boolean
|
|
84
|
-
|
|
85
|
-
::: warning
|
|
86
|
-
When defining `condition` as a function, it must be done in a test file directly, not in a configuration file (configurations are serialized for worker threads).
|
|
87
|
-
:::
|
|
88
|
-
|
|
89
|
-
#### RegExp condition (in config file):
|
|
90
|
-
|
|
91
|
-
```ts
|
|
92
|
-
export default defineConfig({
|
|
93
|
-
test: {
|
|
94
|
-
retry: {
|
|
95
|
-
count: 2,
|
|
96
|
-
condition: /ECONNREFUSED|ETIMEDOUT/i, // Retry on connection/timeout errors
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
})
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
#### Function condition (in test file):
|
|
103
|
-
|
|
104
|
-
```ts
|
|
105
|
-
import { describe, test } from 'vitest'
|
|
106
|
-
|
|
107
|
-
describe('tests with advanced retry condition', () => {
|
|
108
|
-
test('with function condition', { retry: { count: 2, condition: error => error.message.includes('Network') } }, () => {
|
|
109
|
-
// test code
|
|
110
|
-
})
|
|
111
|
-
})
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## Test File Override
|
|
115
|
-
|
|
116
|
-
You can also define retry options per test or suite in test files:
|
|
117
|
-
|
|
118
|
-
```ts
|
|
119
|
-
import { describe, test } from 'vitest'
|
|
120
|
-
|
|
121
|
-
describe('flaky tests', {
|
|
122
|
-
retry: {
|
|
123
|
-
count: 2,
|
|
124
|
-
delay: 100,
|
|
125
|
-
},
|
|
126
|
-
}, () => {
|
|
127
|
-
test('network request', () => {
|
|
128
|
-
// test code
|
|
129
|
-
})
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
test('another test', {
|
|
133
|
-
retry: {
|
|
134
|
-
count: 3,
|
|
135
|
-
condition: error => error.message.includes('timeout'),
|
|
136
|
-
},
|
|
137
|
-
}, () => {
|
|
138
|
-
// test code
|
|
139
|
-
})
|
|
140
|
-
```
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
# runner
|
|
2
|
-
|
|
3
|
-
- **Type:** `VitestRunnerConstructor`
|
|
4
|
-
- **Default:** `node`, when running tests, or `benchmark`, when running benchmarks
|
|
5
|
-
|
|
6
|
-
Path to a custom test runner. This is an advanced feature and should be used with custom library runners. You can read more about it in [the documentation](/api/advanced/runner).
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
# sequence
|
|
2
|
-
|
|
3
|
-
- **Type:** `{ sequencer?, shuffle?, seed?, hooks?, setupFiles?, groupOrder }`
|
|
4
|
-
|
|
5
|
-
Options for how tests should be sorted.
|
|
6
|
-
|
|
7
|
-
You can provide sequence options to CLI with dot notation:
|
|
8
|
-
|
|
9
|
-
```sh
|
|
10
|
-
npx vitest --sequence.shuffle --sequence.seed=1000
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## sequence.sequencer <CRoot />
|
|
14
|
-
|
|
15
|
-
- **Type:** `TestSequencerConstructor`
|
|
16
|
-
- **Default:** `BaseSequencer`
|
|
17
|
-
|
|
18
|
-
A custom class that defines methods for sharding and sorting. You can extend `BaseSequencer` from `vitest/node`, if you only need to redefine one of the `sort` and `shard` methods, but both should exist.
|
|
19
|
-
|
|
20
|
-
Sharding is happening before sorting, and only if `--shard` option is provided.
|
|
21
|
-
|
|
22
|
-
If [`sequence.groupOrder`](#sequence-grouporder) is specified, the sequencer will be called once for each group and pool.
|
|
23
|
-
|
|
24
|
-
## sequence.groupOrder
|
|
25
|
-
|
|
26
|
-
- **Type:** `number`
|
|
27
|
-
- **Default:** `0`
|
|
28
|
-
|
|
29
|
-
Controls the order in which this project runs its tests when using multiple [projects](/guide/projects).
|
|
30
|
-
|
|
31
|
-
- Projects with the same group order number will run together, and groups are run from lowest to highest.
|
|
32
|
-
- If you don't set this option, all projects run in parallel.
|
|
33
|
-
- If several projects use the same group order, they will run at the same time.
|
|
34
|
-
|
|
35
|
-
This setting only affects the order in which projects run, not the order of tests within a project.
|
|
36
|
-
To control test isolation or the order of tests inside a project, use the [`isolate`](/config/isolate) and [`sequence.sequencer`](/config/sequence#sequence-sequencer) options.
|
|
37
|
-
|
|
38
|
-
::: details Example
|
|
39
|
-
Consider this example:
|
|
40
|
-
|
|
41
|
-
```ts
|
|
42
|
-
import { defineConfig } from 'vitest/config'
|
|
43
|
-
|
|
44
|
-
export default defineConfig({
|
|
45
|
-
test: {
|
|
46
|
-
projects: [
|
|
47
|
-
{
|
|
48
|
-
test: {
|
|
49
|
-
name: 'slow',
|
|
50
|
-
sequence: {
|
|
51
|
-
groupOrder: 0,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
test: {
|
|
57
|
-
name: 'fast',
|
|
58
|
-
sequence: {
|
|
59
|
-
groupOrder: 0,
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
test: {
|
|
65
|
-
name: 'flaky',
|
|
66
|
-
sequence: {
|
|
67
|
-
groupOrder: 1,
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
},
|
|
73
|
-
})
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
Tests in these projects will run in this order:
|
|
77
|
-
|
|
78
|
-
```
|
|
79
|
-
0. slow |
|
|
80
|
-
|> running together
|
|
81
|
-
0. fast |
|
|
82
|
-
|
|
83
|
-
1. flaky |> runs after slow and fast alone
|
|
84
|
-
```
|
|
85
|
-
:::
|
|
86
|
-
|
|
87
|
-
## sequence.shuffle
|
|
88
|
-
|
|
89
|
-
- **Type:** `boolean | { files?, tests? }`
|
|
90
|
-
- **Default:** `false`
|
|
91
|
-
- **CLI:** `--sequence.shuffle`, `--sequence.shuffle=false`
|
|
92
|
-
|
|
93
|
-
If you want files and tests to run randomly, you can enable it with this option, or CLI argument [`--sequence.shuffle`](/guide/cli).
|
|
94
|
-
|
|
95
|
-
Vitest usually uses cache to sort tests, so long-running tests start earlier, which makes tests run faster. If your files and tests run in random order, you will lose this performance improvement, but it may be useful to track tests that accidentally depend on another test run previously.
|
|
96
|
-
|
|
97
|
-
### sequence.shuffle.files {#sequence-shuffle-files}
|
|
98
|
-
|
|
99
|
-
- **Type:** `boolean`
|
|
100
|
-
- **Default:** `false`
|
|
101
|
-
- **CLI:** `--sequence.shuffle.files`, `--sequence.shuffle.files=false`
|
|
102
|
-
|
|
103
|
-
Whether to randomize files, be aware that long running tests will not start earlier if you enable this option.
|
|
104
|
-
|
|
105
|
-
### sequence.shuffle.tests {#sequence-shuffle-tests}
|
|
106
|
-
|
|
107
|
-
- **Type:** `boolean`
|
|
108
|
-
- **Default:** `false`
|
|
109
|
-
- **CLI:** `--sequence.shuffle.tests`, `--sequence.shuffle.tests=false`
|
|
110
|
-
|
|
111
|
-
Whether to randomize tests.
|
|
112
|
-
|
|
113
|
-
## sequence.concurrent {#sequence-concurrent}
|
|
114
|
-
|
|
115
|
-
- **Type:** `boolean`
|
|
116
|
-
- **Default:** `false`
|
|
117
|
-
- **CLI:** `--sequence.concurrent`, `--sequence.concurrent=false`
|
|
118
|
-
|
|
119
|
-
If you want tests to run in parallel, you can enable it with this option, or CLI argument [`--sequence.concurrent`](/guide/cli).
|
|
120
|
-
|
|
121
|
-
::: warning
|
|
122
|
-
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).
|
|
123
|
-
:::
|
|
124
|
-
|
|
125
|
-
## sequence.seed <CRoot />
|
|
126
|
-
|
|
127
|
-
- **Type:** `number`
|
|
128
|
-
- **Default:** `Date.now()`
|
|
129
|
-
- **CLI:** `--sequence.seed=1000`
|
|
130
|
-
|
|
131
|
-
Sets the randomization seed, if tests are running in random order.
|
|
132
|
-
|
|
133
|
-
## sequence.hooks
|
|
134
|
-
|
|
135
|
-
- **Type:** `'stack' | 'list' | 'parallel'`
|
|
136
|
-
- **Default:** `'stack'`
|
|
137
|
-
- **CLI:** `--sequence.hooks=<value>`
|
|
138
|
-
|
|
139
|
-
Changes the order in which hooks are executed.
|
|
140
|
-
|
|
141
|
-
- `stack` will order "after" hooks in reverse order, "before" hooks will run in the order they were defined
|
|
142
|
-
- `list` will order all hooks in the order they are defined
|
|
143
|
-
- `parallel` runs hooks in a single group in parallel (hooks in parent suites still run before the current suite's hooks). The actual number of simultaneously running hooks is limited by [`maxConcurrency`](/config/maxconcurrency).
|
|
144
|
-
|
|
145
|
-
::: tip
|
|
146
|
-
This option doesn't affect [`onTestFinished`](/api/hooks#ontestfinished). It is always called in reverse order.
|
|
147
|
-
:::
|
|
148
|
-
|
|
149
|
-
## sequence.setupFiles {#sequence-setupfiles}
|
|
150
|
-
|
|
151
|
-
- **Type:** `'list' | 'parallel'`
|
|
152
|
-
- **Default:** `'parallel'`
|
|
153
|
-
- **CLI:** `--sequence.setupFiles=<value>`
|
|
154
|
-
|
|
155
|
-
Changes the order in which setup files are executed.
|
|
156
|
-
|
|
157
|
-
- `list` will run setup files in the order they are defined
|
|
158
|
-
- `parallel` will run setup files in parallel
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# server <Deprecated />
|
|
2
|
-
|
|
3
|
-
Before Vitest 4, this option was used to define the configuration for the `vite-node` server.
|
|
4
|
-
|
|
5
|
-
At the moment, this option allows you to configure the inlining and externalization mechanisms, along with the module runner debugging configuration.
|
|
6
|
-
|
|
7
|
-
::: warning
|
|
8
|
-
These options should be used only as the last resort to improve performance by externalizing auto-inlined dependencies or to fix issues by inlining invalid external dependencies.
|
|
9
|
-
|
|
10
|
-
Normally, Vitest should do this automatically.
|
|
11
|
-
:::
|
|
12
|
-
|
|
13
|
-
## server.deps
|
|
14
|
-
|
|
15
|
-
### server.deps.external
|
|
16
|
-
|
|
17
|
-
- **Type:** `(string | RegExp)[]`
|
|
18
|
-
- **Default:** files inside [`moduleDirectories`](/config/deps#moduledirectories)
|
|
19
|
-
|
|
20
|
-
Specifies modules that should not be transformed by Vite and should instead be processed directly by the engine. These modules are imported via native dynamic `import` and bypass both transformation and resolution phases.
|
|
21
|
-
|
|
22
|
-
```js [vitest.config.js]
|
|
23
|
-
import { defineConfig } from 'vitest/config'
|
|
24
|
-
|
|
25
|
-
export default defineConfig({
|
|
26
|
-
test: {
|
|
27
|
-
server: {
|
|
28
|
-
deps: {
|
|
29
|
-
external: ['react'],
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
})
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
External modules and their dependencies are not present in the module graph and will not trigger test restarts when they change.
|
|
37
|
-
|
|
38
|
-
Typically, packages under `node_modules` are externalized.
|
|
39
|
-
|
|
40
|
-
::: tip
|
|
41
|
-
If a string is provided, it is first normalized by prefixing the `/node_modules/` or other [`moduleDirectories`](/config/deps#moduledirectories) segments (for example, `'react'` becomes `/node_modules/react/`), and the resulting string is then matched against the full file path. For example, package `@company/some-name` located inside `packages/some-name` should be specified as `some-name`, and `packages` should be included in `deps.moduleDirectories`.
|
|
42
|
-
|
|
43
|
-
If a `RegExp` is provided, it is matched against the full file path.
|
|
44
|
-
:::
|
|
45
|
-
|
|
46
|
-
### server.deps.inline
|
|
47
|
-
|
|
48
|
-
- **Type:** `(string | RegExp)[] | true`
|
|
49
|
-
- **Default:** everything that is not externalized
|
|
50
|
-
|
|
51
|
-
Specifies modules that should be transformed and resolved by Vite. These modules are run by Vite's [module runner](https://vite.dev/guide/api-environment-runtimes#modulerunner).
|
|
52
|
-
|
|
53
|
-
Typically, your source files are inlined.
|
|
54
|
-
|
|
55
|
-
::: tip
|
|
56
|
-
If a string is provided, it is first normalized by prefixing the `/node_modules/` or other [`moduleDirectories`](/config/deps#moduledirectories) segments (for example, `'react'` becomes `/node_modules/react/`), and the resulting string is then matched against the full file path. For example, package `@company/some-name` located inside `packages/some-name` should be specified as `some-name`, and `packages` should be included in `deps.moduleDirectories`.
|
|
57
|
-
|
|
58
|
-
If a `RegExp` is provided, it is matched against the full file path.
|
|
59
|
-
:::
|
|
60
|
-
|
|
61
|
-
### server.deps.fallbackCJS
|
|
62
|
-
|
|
63
|
-
- **Type:** `boolean`
|
|
64
|
-
- **Default:** `false`
|
|
65
|
-
|
|
66
|
-
When enabled, Vitest will try to guess a CommonJS build for an ESM entry by checking a few common CJS/UMD file name and folder patterns (like `.mjs`, `.umd.js`, `.cjs.js`, `umd/`, `cjs/`, `lib/`).
|
|
67
|
-
|
|
68
|
-
This is a best-effort heuristic to work around confusing or incorrect ESM/CJS packaging and may not work for all dependencies.
|