Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/config/fsmodulecache.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ outline: deep
# fsModuleCache <Version>5.0.0</Version>

- **Type:** `boolean`
- **Default:** `false`
- **Default:** `true`
- **CLI:** `--fsModuleCache`, `--fsModuleCache=false`

In watch mode, Vitest caches all transformed files in memory, which makes reruns fast. However, this cache is discarded once the test run finishes. Enabling this option allows Vitest to persist the transformed modules on the file system, so they can be reused across reruns and separate Vitest processes.
In watch mode, Vitest caches all transformed files in memory, which makes reruns fast. However, this cache is discarded once the test run finishes. This option allows Vitest to persist the transformed modules on the file system, so they can be reused across reruns and separate Vitest processes.

A single cache directory is shared by every project in the workspace. By default it lives in `node_modules` at the workspace root (so it is naturally invalidated when dependencies are reinstalled); use [`fsModuleCachePath`](/config/fsmodulecachepath) to change its location. You can delete the cache by running [`vitest --clearCache`](/guide/cli#clearcache).

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/cli-generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ Maximum number of concurrent tests and suites during test file execution (defaul
- **CLI:** `--fsModuleCache`
- **Config:** [fsModuleCache](/config/fsmodulecache)

Cache transformed modules on the file system and reuse them between reruns (default: `false`)
Cache transformed modules on the file system and reuse them between reruns (default: `true`)

### fsModuleCachePath

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/improving-performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ You can limit the working directory when Vitest searches for files using [`test.

## Caching Between Reruns

In watch mode, Vitest caches all transformed files in memory, which makes reruns fast. However, this cache is discarded once the test run finishes. By enabling [`fsModuleCache`](/config/fsmodulecache), Vitest persists this cache to the file system so it can be reused across reruns.
In watch mode, Vitest caches all transformed files in memory, which makes reruns fast. However, this cache is discarded once the test run finishes. With [`fsModuleCache`](/config/fsmodulecache) (enabled by default), Vitest persists this cache to the file system so it can be reused across reruns.

This improvement is most noticeable when rerunning a small number of tests that depend on a large module graph. For full test suites, parallelization already mitigates the cost because other tests populate the in-memory cache while earlier tests are still running. For example, running one test file with a huge module graph (>900 modules):

Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/cli/cli-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ export const cliOptionsConfig: VitestCLIOptions = {
},
fsModuleCache: {
description:
'Cache transformed modules on the file system and reuse them between reruns (default: `false`)',
'Cache transformed modules on the file system and reuse them between reruns (default: `true`)',
},
fsModuleCachePath: {
description:
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/config/resolveConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ export function resolveTestConfig(
resolved.fsModuleCachePath = legacyExperimental.fsModuleCachePath
}
}
resolved.fsModuleCache ??= false
resolved.fsModuleCache ??= true
if (resolved.fsModuleCachePath) {
resolved.fsModuleCachePath = resolve(resolved.root, resolved.fsModuleCachePath)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ export interface InlineConfig {
* Cache transformed modules on the file system and reuse them between reruns
* and separate Vitest processes, which can significantly speed up cold starts.
*
* @default false
* @default true
*/
fsModuleCache?: boolean

Expand Down
1 change: 1 addition & 0 deletions test/e2e/fixtures/doctor/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
watch: false,
fsModuleCache: false,
},
})
Loading