Skip to content

new rule: no-side-effects-wait-for #134

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

Closed
renatoagds opened this issue May 13, 2020 · 7 comments · Fixed by #196
Closed

new rule: no-side-effects-wait-for #134

renatoagds opened this issue May 13, 2020 · 7 comments · Fixed by #196
Assignees
Labels
new rule New rule to be included in the plugin released on @beta released
Milestone

Comments

@renatoagds
Copy link
Contributor

renatoagds commented May 13, 2020

Following the proposed for Kent at his post (https://kentcdodds.com/blog/common-mistakes-with-react-testing-library). I would like to suggest a new rule that detects side effects inside a wait-for:

 // wrong
await waitFor(() => {
  fireEvent.click(a)
  expect(b).toEqual('b')
})
 // correct
fireEvent.click(a)
await waitFor(() => expect(b).toEqual('b'))
@Belco90 Belco90 closed this as completed May 13, 2020
@Belco90 Belco90 reopened this May 13, 2020
@Belco90 Belco90 added the new rule New rule to be included in the plugin label May 13, 2020
@Belco90
Copy link
Member

Belco90 commented May 13, 2020

Sorry, I closed this one by mistake! Thanks again Renato, this suggestion sounds good too.

We would have to identify which side effects we want to check here, I guess those from testing library itself.

Again, would like to give it a try? PRs are welcome!

@renatoagds
Copy link
Contributor Author

We would have to identify which side effects we want to check here, I guess those from testing library itself.

@Belco90 Yes! I was think to add fireEvent and userEvent initially. Sounds good?

@Belco90
Copy link
Member

Belco90 commented May 13, 2020

Sounds good!

@renatoagds
Copy link
Contributor Author

Just to update! I'm finishing #133 this week and will start work on this one 🚀

@Belco90
Copy link
Member

Belco90 commented Jun 22, 2020

Awesome, thanks for your help 💪

@github-actions
Copy link

🎉 This issue has been resolved in version 4.0.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This issue has been resolved in version 4.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new rule New rule to be included in the plugin released on @beta released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants