testing-library / react-hooks-testing-library

🐏 Simple and complete React hooks testing utilities that encourage good testing practices.
https://react-hooks-testing-library.com
MIT License
5.26k stars 233 forks source link

React 18 migration for waitForNextUpdate repeats steps for waitForValueToChange instead #975

Open sfc-gh-mgolebiowskiowczarek opened 1 month ago

sfc-gh-mgolebiowskiowczarek commented 1 month ago

Relevant code or config:

N/A

What you did:

I read https://github.com/testing-library/react-hooks-testing-library/blob/chore/migration-guide/MIGRATION_GUIDE.md#waitfornextupdate (section waitForNextUpdate).

What happened:

That section shows the following code snippet:

-await waitForValueToChange(() => result.current.state);
+const initialValue = result.current;
+await waitFor(() => {
+  expect(result.current).not.toBe(initialValue);
+});

Reproduction:

N/A, this is a docs change.

Problem description:

As you can see, it actually shows the migration path for waitForValueToChange which was already handled in the previous section. The code seems erroneously repeated.

Suggested solution:

Provide a proper code migration path, where the "before" state actually uses the waitForNextUpdate API.