Skip to content

Commit

Permalink
feat(async-utils): async utils advance fake timer automatically when …
Browse files Browse the repository at this point in the history
…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 <leichen@Leis-MacBook-Pro.local>
Co-authored-by: Michael Peyper <mpeyper7@gmail.com>
  • Loading branch information
3 people committed Sep 19, 2021
1 parent 8b72a87 commit 732ec46
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 230 deletions.
1 change: 1 addition & 0 deletions .all-contributorsrc
Expand Up @@ -582,6 +582,7 @@
"avatar_url": "https://avatars.githubusercontent.com/u/10645051?v=4",
"profile": "https://github.com/chris110408",
"contributions": [
"code",
"test"
]
},
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -247,7 +247,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<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>
<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>
<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>
<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>
<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>
<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>
</tr>
</table>
Expand Down
58 changes: 0 additions & 58 deletions src/__tests__/asyncHook.fakeTimers.test.ts

This file was deleted.

0 comments on commit 732ec46

Please sign in to comment.