new rule: no-multiple-assertions-wait-for
See original GitHub issueFollowing the proposed in Kent at his post (https://kentcdodds.com/blog/common-mistakes-with-react-testing-library). I would like to suggest a new rule that detects multiple expect inside a wait-for:
❌ // wrong
await waitFor(() => {
expect(a).toEqual('a')
expect(b).toEqual('b')
})
✅ // correct
await waitFor(() => expect(a).toEqual('a'))
expect(b).toEqual('b')
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:12 (8 by maintainers)
Top Results From Across the Web
eslint-plugin-testing-library/no-wait-for-multiple-assertions.md ...
Disallow the use of multiple expect calls inside waitFor ( testing-library/no-wait-for-multiple-assertions ). This rule is enabled in the following ...
Read more >Is it okay to use the expect inside of a waitFor as my "Assert" in ...
The point of my question is just whether it's OK for the assertion to be wrapped within a waitFor, which I am thinking...
Read more >Testing-library: avoid these mistakes in async tests
waitFor is triggered multiple times because at least one of the assertions fails. Let's go through the sequence of calls, where each list...
Read more >eslint-plugin-testing-library - npm
Supported Rules ; no-wait-for-multiple-assertions, Disallow the use of multiple expect calls inside waitFor, dom-badge angular-badge react-badge ...
Read more >React Testing Library best practices | Ben Ilegbodu
The waitFor method is a powerful asynchronous utility to enable us to make an assertion after a non-deterministic amount of time. The way ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@renatoagds sorry, didn’t know you were still working on it! I’m happy with your suggestion to start only with
waitFor
and see what feedback we get. It’s a good idea also to rename the rule tono-multiple-assertions-wait-for
. Thanks!Maybe
no-multiple-assertions-wait-for
?