cache
- 类型:
boolean - 默认值:
true - 命令行终端:
--cache,--no-cache
Store the results of test runs on the file system. Vitest uses them to run failed and longer test files first and to select tests with --last-failed.
For every test file, Vitest stores whether the file failed, which tests failed, how long it ran and when it ran last. A run that did not execute the whole file (for example, a run filtered with --testNamePattern or cancelled by bail) can mark the file as failed, but it cannot mark it as passed.
You can delete the cache by running vitest --clearCache.
缓存目录由 Vite 的 cacheDir 选项控制:
ts
import { defineConfig } from 'vitest/config'
export default defineConfig({
cacheDir: 'custom-folder/.vitest'
})可通过 process.env.VITEST 将目录限制为仅 Vitest 使用:
ts
import { defineConfig } from 'vitest/config'
export default defineConfig({
cacheDir: process.env.VITEST ? 'custom-folder/.vitest' : undefined
})注意
The deprecated cache.dir option has no effect anymore. Use cacheDir to change the cache directory.