Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(fakeTimers): Explain how to use fake timers in testing-library #528

Merged
merged 8 commits into from
Jul 28, 2020

Conversation

MatanBobi
Copy link
Member

@MatanBobi MatanBobi commented Jul 21, 2020

Following the conversation in testing-library/react-testing-library#743 (comment) with @kentcdodds and @eps1lon,
I've created this page to explain the work with fake timers in testing-library.
I wasn't 100% sure where to put this section so for now I put it under the Getting Started section since this is relevant knowledge for all testing library frameworks (I really think we should build a General section).
This PR closes #523

Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outline looks great. Some specific parts I'm not quite sure about.

docs/using-fake-timers.md Outdated Show resolved Hide resolved
docs/using-fake-timers.md Outdated Show resolved Hide resolved
docs/using-fake-timers.md Outdated Show resolved Hide resolved
@MatanBobi
Copy link
Member Author

Well, I'm still not 100% happy with the phrasing there but I've updated it based on the comments,
Thanks! :)

docs/using-fake-timers.md Outdated Show resolved Hide resolved
Co-authored-by: Sebastian Silbermann <[email protected]>
sidebar_label: Using Fake Timers
---

Using real timers in your tests is problematic since they depend on real time
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the wording here strongly advises the use of fake timers 100% of the time or as the default. I don't know about anyone else, but fake timers as complexity to test code and only sometimes provide any benefit and I therefore only use them when I really want to fake timers (like a debounce). Either way, I don't think this mentions the drawbacks fairly and I think we should do so. I don't think people should come away from reading this with the ideas that fake timers should be their default way for testing. Maybe we could add a section for when fake timers are worth the trouble?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you're right, it's pretty misleading, I'll work on that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry it took me some time, I rephrased it.
I think it's still not 100% explanatory though, wasn't really sure how I can expand it..

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's perfect 👍

@kentcdodds kentcdodds merged commit 78e75ae into testing-library:master Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10.4.4 causing timeout issue with useEffect+jest.useFakeTimers
3 participants