-
Notifications
You must be signed in to change notification settings - Fork 711
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
docs(fakeTimers): Explain how to use fake timers in testing-library #528
Conversation
There was a problem hiding this 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.
Well, I'm still not 100% happy with the phrasing there but I've updated it based on the comments, |
Co-authored-by: Sebastian Silbermann <[email protected]>
docs/using-fake-timers.md
Outdated
sidebar_label: Using Fake Timers | ||
--- | ||
|
||
Using real timers in your tests is problematic since they depend on real time |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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..
…ers should only be sporadically used.
…-library-docs into pr/explain-fake-timers
There was a problem hiding this 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 👍
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 aGeneral
section).This PR closes #523