Skip to content

Commit d4fe198

Browse files
authored
feat: promote clearCache out of experimental (#11086)
1 parent 3f2ddc2 commit d4fe198

4 files changed

Lines changed: 17 additions & 10 deletions

File tree

docs/api/advanced/vitest.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,16 +597,16 @@ function parseSpecifications(
597597

598598
This method will [collect tests](#parsespecification) from an array of specifications. By default, Vitest will run only `os.availableParallelism()` number of specifications at a time to reduce the potential performance degradation. You can specify a different number in a second argument.
599599

600-
This was available since Vitest 4.0.0 as experimental `experimental_parseSpecifications` method.
601-
602-
## experimental_clearCache <Version type="experimental">4.0.11</Version> <Experimental /> {#clearcache}
600+
## clearCache <Version>5.0.0</Version> {#clearcache}
603601

604602
```ts
605-
function experimental_clearCache(): Promise<void>
603+
function clearCache(): Promise<void>
606604
```
607605

608606
Deletes all Vitest caches, including [`fsModuleCache`](/config/fsmodulecache).
609607

608+
This was available since Vitest 4.0.11 as experimental `experimental_clearCache` method.
609+
610610
## experimental_getSourceModuleDiagnostic <Version type="experimental">4.0.15</Version> <Experimental /> {#getsourcemodulediagnostic}
611611

612612
```ts

packages/vitest/src/node/cli/cli-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export async function startVitest(
151151
await ctx.listTags()
152152
}
153153
else if (ctx.config.clearCache) {
154-
await ctx.experimental_clearCache()
154+
await ctx.clearCache()
155155
}
156156
else if (ctx.config.mergeReports) {
157157
await ctx.mergeReports()

packages/vitest/src/node/core.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,11 +669,18 @@ export class Vitest {
669669
return this._coverageProvider
670670
}
671671

672+
/**
673+
* @deprecated Use `clearCache` instead.
674+
*/
675+
public experimental_clearCache(): Promise<void> {
676+
this.logger.deprecate(`The "experimental_clearCache" method is deprecated. Use "clearCache" instead.`)
677+
return this.clearCache()
678+
}
679+
672680
/**
673681
* Deletes all Vitest caches, including the `fsModuleCache`.
674-
* @experimental
675682
*/
676-
public async experimental_clearCache(): Promise<void> {
683+
public async clearCache(): Promise<void> {
677684
await this.cache.results.clearCache()
678685
await this._fsCache.clearCache()
679686
}

test/e2e/test/caching.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ test('if no cache key generator is defined, the hash is invalid', async () => {
6060
{
6161
async onInit(vitest) {
6262
// make sure cache is empty
63-
await vitest.experimental_clearCache()
63+
await vitest.clearCache()
6464
},
6565
},
6666
],
@@ -106,7 +106,7 @@ test('if cache key generator is defined, the hash is valid', async () => {
106106
{
107107
async onInit(vitest) {
108108
// make sure cache is empty
109-
await vitest.experimental_clearCache()
109+
await vitest.clearCache()
110110
},
111111
},
112112
],
@@ -150,7 +150,7 @@ test('if cache key generator bails out, the file is not cached', async () => {
150150
{
151151
async onInit(vitest) {
152152
// make sure cache is empty
153-
await vitest.experimental_clearCache()
153+
await vitest.clearCache()
154154
},
155155
},
156156
],

0 commit comments

Comments
 (0)