feat(waitFor): Automatically advance Jest fake timers
What:
Closes https://github.com/testing-library/react-hooks-testing-library/issues/873
Why:
There's little value in waitFor if one has to advance timers by themselves.
How:
Copy implementation from @testing-library/dom.
There's an opportunity to write a more generic waitFor that we can share across Testing Library that specific host configs build on top on (e.g. also running MutationObserver in /dom). But that requires more coordination (starting with an extensive test suite). For now this hopefully suffices (pending testing in actual codebases).
Checklist:
- [ ] Documentation updated
- [ ] Tests
- [ ] timing out
- [ ] timing out without a callback error
- [ ] switching to real timers
- [ ] Test in actual codebase
- [ ] Ready to be merged
- [ ] Added myself to contributors table
Deploy Preview for react-hooks-testing-library failed.
| Name | Link |
|---|---|
| Latest commit | 18bfadf72c0dd996ecdce8de53c7c1bb0866b6a9 |
| Latest deploy log | https://app.netlify.com/sites/react-hooks-testing-library/deploys/62d7140dcdefdf00088cc613 |
Why not tell people to use https://github.com/facebook/jest/blob/6fc1860a34ea64a7c3360580e2874c94a5c8fc83/packages/jest-types/src/Config.ts#L43-L51?