react-hooks-testing-library icon indicating copy to clipboard operation
react-hooks-testing-library copied to clipboard

feat(waitFor): Automatically advance Jest fake timers

Open eps1lon opened this issue 3 years ago • 2 comments

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

eps1lon avatar Jul 19 '22 20:07 eps1lon

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

netlify[bot] avatar Jul 19 '22 20:07 netlify[bot]

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

SimenB avatar Nov 14 '22 15:11 SimenB