Skip to content

Commit 5fc498f

Browse files
authored
chore(docs): add waitForValueToChange shim to migration guide (#924)
* Update MIGRATION_GUIDE.md
1 parent 5ba7fe9 commit 5fc498f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

MIGRATION_GUIDE.md

+14
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@ APIs. A similar result can be achieved by using `waitFor`:
115115
+});
116116
```
117117

118+
Alternatively this utility can be implemented as the following, for a direct migration:
119+
120+
```ts
121+
import { waitFor } from '@testing-library/react';
122+
123+
const waitForValueToChange = async <T>(getValue: () => T) => {
124+
const original = getValue();
125+
126+
await waitFor(async () => {
127+
expect(await original).not.toBe(await getValue());
128+
});
129+
};
130+
```
131+
118132
## `waitForNextUpdate`
119133

120134
This utility has not been included in the React Testing Library or React Native Testing Library

0 commit comments

Comments
 (0)