question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

new rule: no-multiple-assertions-wait-for

See original GitHub issue

Following 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:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
Belco90commented, Jun 18, 2020

@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 to no-multiple-assertions-wait-for. Thanks!

2reactions
nickmccurdycommented, Jun 17, 2020

Maybe no-multiple-assertions-wait-for?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found