From 3082bbdfb9b28d60bea2518378672c4249942bac Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Tue, 6 Aug 2024 16:10:53 +0200 Subject: [PATCH 1/3] fix(vitest): don't expose default toFake config --- packages/vitest/src/defaults.ts | 9 --------- 1 file changed, 9 deletions(-) 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 = { From 9078e3a66718d5a0db50a421a7b98ff775be7b6a Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Tue, 6 Aug 2024 16:13:45 +0200 Subject: [PATCH 2/3] docs: mention the change --- docs/config/index.md | 2 +- patches/@types__sinonjs__fake-timers@8.1.5.patch | 2 +- 2 files changed, 2 insertions(+), 2 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/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; From 611bd645a888b0dabe0057b5f874fa78d23e4216 Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Thu, 5 Dec 2024 15:08:44 +0100 Subject: [PATCH 3/3] chore: cleanup --- pnpm-lock.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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