From e3144fd8dab55f659190c6308864428e290d08dc Mon Sep 17 00:00:00 2001 From: Vladimir Date: Thu, 5 Dec 2024 15:23:40 +0100 Subject: [PATCH] fix(vitest)!: don't expose default toFake config (#6288) --- docs/config/index.md | 2 +- packages/vitest/src/defaults.ts | 9 --------- patches/@types__sinonjs__fake-timers@8.1.5.patch | 2 +- pnpm-lock.yaml | 8 ++++---- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/docs/config/index.md b/docs/config/index.md index ed8717bca9bf..b99a3ae1b4e6 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -2527,7 +2527,7 @@ Installs fake timers with the specified Unix epoch. #### fakeTimers.toFake - **Type:** `('setTimeout' | 'clearTimeout' | 'setImmediate' | 'clearImmediate' | 'setInterval' | 'clearInterval' | 'Date' | 'nextTick' | 'hrtime' | 'requestAnimationFrame' | 'cancelAnimationFrame' | 'requestIdleCallback' | 'cancelIdleCallback' | 'performance' | 'queueMicrotask')[]` -- **Default:** `['setTimeout', 'clearTimeout', 'setImmediate', 'clearImmediate', 'setInterval', 'clearInterval', 'Date']` +- **Default:** everything available globally except `nextTick` An array with names of global methods and APIs to fake. diff --git a/packages/vitest/src/defaults.ts b/packages/vitest/src/defaults.ts index b765116d30ca..c2abf2b60f79 100644 --- a/packages/vitest/src/defaults.ts +++ b/packages/vitest/src/defaults.ts @@ -88,15 +88,6 @@ export const coverageConfigDefaults: ResolvedCoverageOptions = { export const fakeTimersDefaults = { loopLimit: 10_000, shouldClearNativeTimers: true, - toFake: [ - 'setTimeout', - 'clearTimeout', - 'setInterval', - 'clearInterval', - 'setImmediate', - 'clearImmediate', - 'Date', - ], } satisfies NonNullable const config = { diff --git a/patches/@types__sinonjs__fake-timers@8.1.5.patch b/patches/@types__sinonjs__fake-timers@8.1.5.patch index 4f52bfa71f59..47cd33ebb3b6 100644 --- a/patches/@types__sinonjs__fake-timers@8.1.5.patch +++ b/patches/@types__sinonjs__fake-timers@8.1.5.patch @@ -10,7 +10,7 @@ index 5aa018cde4336aca4dadefb8338549c378792e14..2e0c38efc15e793dc37e401e25130162 - * For instance, `FakeTimers.install({ toFake: ['setTimeout', 'nextTick'] })` will fake only `setTimeout()` and `nextTick()` + * An array with names of global methods and APIs to fake. + * For instance, `vi.useFakeTimer({ toFake: ['setTimeout', 'performance'] })` will fake only `setTimeout()` and `performance.now()` -+ * @default ['setTimeout', 'clearTimeout', 'setImmediate', 'clearImmediate', 'setInterval', 'clearInterval', 'Date'] ++ * @default everything available globally except `nextTick` */ toFake?: FakeMethod[] | undefined; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b4dfb6f205b4..12f65a6d7e65 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -21,7 +21,7 @@ patchedDependencies: hash: s5kzatt2y2dzfxfynxzvzt5kbm path: patches/@types__chai@4.3.6.patch '@types/sinonjs__fake-timers@8.1.5': - hash: ggdsr7nrdrzokhhihsihc2hdja + hash: yuuqouzdhxwdvk3q6qf2uf434a path: patches/@types__sinonjs__fake-timers@8.1.5.patch acorn@8.11.3: hash: no36qihqjrd3chyjw73dk5xfkm @@ -949,7 +949,7 @@ importers: version: 2.4.9 '@types/sinonjs__fake-timers': specifier: ^8.1.5 - version: 8.1.5(patch_hash=ggdsr7nrdrzokhhihsihc2hdja) + version: 8.1.5(patch_hash=yuuqouzdhxwdvk3q6qf2uf434a) acorn-walk: specifier: ^8.3.4 version: 8.3.4 @@ -12205,7 +12205,7 @@ snapshots: '@types/resolve@1.20.2': {} - '@types/sinonjs__fake-timers@8.1.5(patch_hash=ggdsr7nrdrzokhhihsihc2hdja)': {} + '@types/sinonjs__fake-timers@8.1.5(patch_hash=yuuqouzdhxwdvk3q6qf2uf434a)': {} '@types/stack-utils@2.0.3': optional: true @@ -19114,7 +19114,7 @@ snapshots: webdriverio@9.4.1: dependencies: '@types/node': 20.14.15 - '@types/sinonjs__fake-timers': 8.1.5(patch_hash=ggdsr7nrdrzokhhihsihc2hdja) + '@types/sinonjs__fake-timers': 8.1.5(patch_hash=yuuqouzdhxwdvk3q6qf2uf434a) '@wdio/config': 9.2.8 '@wdio/logger': 9.1.3 '@wdio/protocols': 9.2.2