Skip to content

Commit 732ec46

Browse files
chris110408Lei Chenmpeyper
authored
feat(async-utils): async utils advance fake timer automatically when waiting
Fixes #631 * add jestFakeTimersAreEnabled and use it to detect faketimer in createTimeoutController (#688) * fix fakeTimer problem * add new fakeTimer test and revise the function * add advanceTime * revise the advanceTime * use jest.advanceTimersByTime * change timeout type * fix converage and revise type * test(fake-timers): add more tests to test suite for fake timers * fix the code after code review and clean up * fix the test timeout is false * clean up * fix coverage * add skip for pass checkers * add comment * test(async-utils): enable test to test CI fix * test(async-utils): combine fake timer tests with async tests * refactor(async-utils): Move DEFAULT_TIMEOUT out of timeout controller * refactor(async-utils): move fake timer advancement into seperate utility * refactor(async-utils): simplify fake timer advancement logic * docs: add chris110408 as a contributor for code * refactor(async-utils): only advance timers on a single timeoutController BREAKING CHANGE: tests that used to manually advance fake timers and use async utilities may now fail as timer would advance further Co-authored-by: Lei Chen <[email protected]> Co-authored-by: Michael Peyper <[email protected]>
1 parent 8b72a87 commit 732ec46

7 files changed

+224
-230
lines changed

.all-contributorsrc

+1
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@
582582
"avatar_url": "https://avatars.githubusercontent.com/u/10645051?v=4",
583583
"profile": "https://github.com/chris110408",
584584
"contributions": [
585+
"code",
585586
"test"
586587
]
587588
},

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
247247
<td align="center"><a href="https://github.com/andyrooger"><img src="https://avatars.githubusercontent.com/u/420834?v=4?s=100" width="100px;" alt=""/><br /><sub><b>andyrooger</b></sub></a><br /><a href="https://github.com/testing-library/react-hooks-testing-library/commits?author=andyrooger" title="Code">💻</a></td>
248248
<td align="center"><a href="https://github.com/bdwain"><img src="https://avatars.githubusercontent.com/u/3982094?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Bryan Wain</b></sub></a><br /><a href="https://github.com/testing-library/react-hooks-testing-library/issues?q=author%3Abdwain" title="Bug reports">🐛</a> <a href="https://github.com/testing-library/react-hooks-testing-library/pulls?q=is%3Apr+reviewed-by%3Abdwain" title="Reviewed Pull Requests">👀</a></td>
249249
<td align="center"><a href="https://github.com/snowystinger"><img src="https://avatars.githubusercontent.com/u/698229?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Robert Snow</b></sub></a><br /><a href="https://github.com/testing-library/react-hooks-testing-library/commits?author=snowystinger" title="Tests">⚠️</a></td>
250-
<td align="center"><a href="https://github.com/chris110408"><img src="https://avatars.githubusercontent.com/u/10645051?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Chris Chen</b></sub></a><br /><a href="https://github.com/testing-library/react-hooks-testing-library/commits?author=chris110408" title="Tests">⚠️</a></td>
250+
<td align="center"><a href="https://github.com/chris110408"><img src="https://avatars.githubusercontent.com/u/10645051?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Chris Chen</b></sub></a><br /><a href="https://github.com/testing-library/react-hooks-testing-library/commits?author=chris110408" title="Code">💻</a> <a href="https://github.com/testing-library/react-hooks-testing-library/commits?author=chris110408" title="Tests">⚠️</a></td>
251251
<td align="center"><a href="https://www.facebook.com/masoud.bonabi"><img src="https://avatars.githubusercontent.com/u/6429009?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Masious</b></sub></a><br /><a href="https://github.com/testing-library/react-hooks-testing-library/commits?author=masious" title="Documentation">📖</a></td>
252252
</tr>
253253
</table>

src/__tests__/asyncHook.fakeTimers.test.ts

-58
This file was deleted.

0 commit comments

Comments
 (0)