From 90d216a81f315a655d8d5c473cbeb1057d51abea Mon Sep 17 00:00:00 2001 From: Opender Singh Date: Fri, 18 Nov 2022 15:39:38 +1300 Subject: [PATCH 1/2] Update MIGRATION_GUIDE.md --- MIGRATION_GUIDE.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index e90da886..a94159e2 100644 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -115,6 +115,20 @@ APIs. A similar result can be achieved by using `waitFor`: +}); ``` +Alternatively this utility can be implemented as the following, for a direct migration: + +```ts +import { waitFor } from '@testing-library/react'; + +const waitForValueToChange = async (getValue: () => T) => { + const original = getValue(); + + await waitFor(async () => { + expect(await original).not.toBe(await getValue()); + }); +}; +``` + ## `waitForNextUpdate` This utility has not been included in the React Testing Library or React Native Testing Library From aeea85b78a5ea5cc27270bf37538ff0ea66e46e3 Mon Sep 17 00:00:00 2001 From: Opender Singh Date: Fri, 18 Nov 2022 21:16:04 +1300 Subject: [PATCH 2/2] Update MIGRATION_GUIDE.md --- MIGRATION_GUIDE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index a94159e2..07f0eef9 100644 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -120,7 +120,7 @@ Alternatively this utility can be implemented as the following, for a direct mig ```ts import { waitFor } from '@testing-library/react'; -const waitForValueToChange = async (getValue: () => T) => { +const waitForValueToChange = async (getValue: () => T) => { const original = getValue(); await waitFor(async () => {