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

feat(waitFor): Automatically advance Jest fake timers #878

Open eps1lon opened 2 years ago

eps1lon commented 2 years ago

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:

netlify[bot] commented 2 years ago

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
SimenB commented 1 year ago

Why not tell people to use https://github.com/facebook/jest/blob/6fc1860a34ea64a7c3360580e2874c94a5c8fc83/packages/jest-types/src/Config.ts#L43-L51?