[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

docs: add default for `fakeTimers.toFake` (#5197)

Co-authored-by: Anjorin Damilare <damilareanjorin1@gmail.com>
Co-authored-by: Vladimir <sleuths.slews0s@icloud.com>

authored by

Hiroshi Ogawa
Anjorin Damilare
Vladimir
and committed by
GitHub
(Mar 26, 2024, 3:28 PM +0100) 2e8e05e6 fee7d8be

+46 -6
+2 -1
package.json
··· 83 83 "patchedDependencies": { 84 84 "@types/chai@4.3.6": "patches/@types__chai@4.3.6.patch", 85 85 "@sinonjs/fake-timers@11.1.0": "patches/@sinonjs__fake-timers@11.1.0.patch", 86 - "cac@6.7.14": "patches/cac@6.7.14.patch" 86 + "cac@6.7.14": "patches/cac@6.7.14.patch", 87 + "@types/sinonjs__fake-timers@8.1.5": "patches/@types__sinonjs__fake-timers@8.1.5.patch" 87 88 } 88 89 }, 89 90 "simple-git-hooks": {
+6 -2
pnpm-lock.yaml
··· 16 16 '@types/chai@4.3.6': 17 17 hash: s5kzatt2y2dzfxfynxzvzt5kbm 18 18 path: patches/@types__chai@4.3.6.patch 19 + '@types/sinonjs__fake-timers@8.1.5': 20 + hash: ggdsr7nrdrzokhhihsihc2hdja 21 + path: patches/@types__sinonjs__fake-timers@8.1.5.patch 19 22 cac@6.7.14: 20 23 hash: slh3cigivjjjktoa42g2agwaem 21 24 path: patches/cac@6.7.14.patch ··· 1420 1423 version: 2.4.9 1421 1424 '@types/sinonjs__fake-timers': 1422 1425 specifier: ^8.1.5 1423 - version: 8.1.5 1426 + version: 8.1.5(patch_hash=ggdsr7nrdrzokhhihsihc2hdja) 1424 1427 birpc: 1425 1428 specifier: 0.2.15 1426 1429 version: 0.2.15 ··· 9931 9934 resolution: {integrity: sha512-0kSuKjAS0TrGLJ0M/+8MaFkGsQhZpB6pxOmvS3K8FYI72K//YmdfoW9X2qPsAKh1mkwxGD5zib9s1FIFed6E8g==} 9932 9935 dev: true 9933 9936 9934 - /@types/sinonjs__fake-timers@8.1.5: 9937 + /@types/sinonjs__fake-timers@8.1.5(patch_hash=ggdsr7nrdrzokhhihsihc2hdja): 9935 9938 resolution: {integrity: sha512-mQkU2jY8jJEF7YHjHvsQO8+3ughTL1mcnn96igfhONmR+fUPSKIkefQYpSe8bsly2Ep7oQbn/6VG5/9/0qcArQ==} 9936 9939 dev: true 9940 + patched: true 9937 9941 9938 9942 /@types/sizzle@2.3.3: 9939 9943 resolution: {integrity: sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ==}
+34
patches/@types__sinonjs__fake-timers@8.1.5.patch
··· 1 + diff --git a/index.d.ts b/index.d.ts 2 + index 5aa018cde4336aca4dadefb8338549c378792e14..2e0c38efc15e793dc37e401e2513016247058f37 100644 3 + --- a/index.d.ts 4 + +++ b/index.d.ts 5 + @@ -329,13 +329,15 @@ export interface FakeTimerInstallOpts { 6 + now?: number | Date | undefined; 7 + 8 + /** 9 + - * An array with names of global methods and APIs to fake. By default, `@sinonjs/fake-timers` does not replace `nextTick()` and `queueMicrotask()`. 10 + - * For instance, `FakeTimers.install({ toFake: ['setTimeout', 'nextTick'] })` will fake only `setTimeout()` and `nextTick()` 11 + + * An array with names of global methods and APIs to fake. 12 + + * For instance, `vi.useFakeTimer({ toFake: ['setTimeout', 'performance'] })` will fake only `setTimeout()` and `performance.now()` 13 + + * @default ['setTimeout', 'clearTimeout', 'setImmediate', 'clearImmediate', 'setInterval', 'clearInterval', 'Date'] 14 + */ 15 + toFake?: FakeMethod[] | undefined; 16 + 17 + /** 18 + - * The maximum number of timers that will be run when calling runAll() (default: 1000) 19 + + * The maximum number of timers that will be run when calling runAll() 20 + + * @default 10000 21 + */ 22 + loopLimit?: number | undefined; 23 + 24 + @@ -352,8 +354,8 @@ export interface FakeTimerInstallOpts { 25 + advanceTimeDelta?: number | undefined; 26 + 27 + /** 28 + - * Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers. These are not cleared by 29 + - * default, leading to potentially unexpected behavior if timers existed prior to installing FakeTimers. (default: false) 30 + + * Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers. 31 + + * @default true 32 + */ 33 + shouldClearNativeTimers?: boolean | undefined; 34 + }
+1 -1
docs/api/vi.md
··· 738 738 739 739 - **Type:** `(config?: FakeTimerInstallOpts) => Vitest` 740 740 741 - To enable mocking timers, you need to call this method. It will wrap all further calls to timers (such as `setTimeout`, `setInterval`, `clearTimeout`, `clearInterval`, `nextTick`, `setImmediate`, `clearImmediate`, and `Date`), until [`vi.useRealTimers()`](#vi-userealtimers) is called. 741 + To enable mocking timers, you need to call this method. It will wrap all further calls to timers (such as `setTimeout`, `setInterval`, `clearTimeout`, `clearInterval`, `setImmediate`, `clearImmediate`, and `Date`) until [`vi.useRealTimers()`](#vi-userealtimers) is called. 742 742 743 743 Mocking `nextTick` is not supported when running Vitest inside `node:child_process` by using `--pool=forks`. NodeJS uses `process.nextTick` internally in `node:child_process` and hangs when it is mocked. Mocking `nextTick` is supported when running Vitest with `--pool=threads`. 744 744
+3 -2
docs/config/index.md
··· 2046 2046 2047 2047 #### fakeTimers.toFake 2048 2048 2049 - - **Type:** `FakeMethod[]` 2049 + - **Type:** `('setTimeout' | 'clearTimeout' | 'setImmediate' | 'clearImmediate' | 'setInterval' | 'clearInterval' | 'Date' | 'nextTick' | 'hrtime' | 'requestAnimationFrame' | 'cancelAnimationFrame' | 'requestIdleCallback' | 'cancelIdleCallback' | 'performance' | 'queueMicrotask')[]` 2050 + - **Default:** `['setTimeout', 'clearTimeout', 'setImmediate', 'clearImmediate', 'setInterval', 'clearInterval', 'Date']` 2050 2051 2051 - An array with names of global methods and APIs to fake. By default, Vitest does not replace `nextTick()` and `queueMicrotask()`. 2052 + An array with names of global methods and APIs to fake. 2052 2053 2053 2054 To only mock `setTimeout()` and `nextTick()`, specify this property as `['setTimeout', 'nextTick']`. 2054 2055