From 64a9c1fee86251cd09a0b2f253ae14a214f0ae76 Mon Sep 17 00:00:00 2001 From: Anderson Entwistle <46688047+aentwist@users.noreply.github.com> Date: Tue, 20 Jun 2023 14:42:13 -0400 Subject: [PATCH] docs: note Vue's dependence on system time (#2100) --- docs/api/index.md | 2 ++ docs/guide/faq/index.md | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/docs/api/index.md b/docs/api/index.md index 99ac3904c..1e63d406b 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -7,6 +7,8 @@ sidebar: auto ## mount Creates a Wrapper that contains the mounted and rendered Vue component to test. +Note that when mocking dates/timers with Vitest, this must be called after +`vi.setSystemTime`. **Signature:** diff --git a/docs/guide/faq/index.md b/docs/guide/faq/index.md index 1c883cab8..9f89a26b8 100644 --- a/docs/guide/faq/index.md +++ b/docs/guide/faq/index.md @@ -2,6 +2,15 @@ [[toc]] +## Mocking Dates and Timers with Vitest + +Vue's scheduler depends on the system time. Make sure to mount components +*after* calling `vi.setSystemTime`, since Vue depends on its side effects. +Mounting components before calling `vi.setSystemTime` may cause breaks in +reactivity. + +See [vuejs/test-utils#2074](https://github.com/vuejs/test-utils/issues/2074). + ## Vue warn: Failed setting prop ```