Combine multiple wait-for rules into one #264
Replies: 3 comments
-
Hey @thomlom! I like the main idea explained here and I'm happy to have this discussion. However, there have been tons of changes already for v4, which is not even finished yet and has been around for a while, so I don't want to increase the list of breaking changes for it. Instead, I'd like to leave rules combinations and standardization for a future v5. I was already thinking about combining ones related to await async stuff or extract the framework setting from About combining waitFor rules. I wouldn't be worried about the granularity of having several rules, as you mentioned that could be configured over rule options. Regarding your main point of "it seems like waitFor must be used in one way: by putting a single assertion inside the callback." this is not technically true by different reasons:
So it doesn't seem |
Beta Was this translation helpful? Give feedback.
-
Yes, I agree it'll be a lot of changes for v4. I also think the async stuff could be mutualized with other rules. I didn't know about the other use cases for |
Beta Was this translation helpful? Give feedback.
-
I moved this issue to a discussion thread! |
Beta Was this translation helpful? Give feedback.
-
We have multiples rules related to the use of
waitFor
in the v4:After reading Common mistakes with React Testing Library, it seems like
waitFor
must be used in one way: by putting a single assertion inside the callback.For example:
I feel like the rules above could be simplified and combined into one single rule that makes sure you only expect one assertion in the callback. That would make our rules simpler and easier to maintain. Plus, the developer wouldn't have to enable multiple rules but one which would give him a better experience.
The downside I see is that these rules have different levels of criticality, some of them are included by default and others don't. Combining it into one would make the rule too opinionated (though we can still configure it in the options).
I don't know if there are other legit use cases for
waitFor
so any feedback on that is appreciated.Beta Was this translation helpful? Give feedback.
All reactions