Skip to content

Pr/fix async checks when calling queries member expressions #114

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

Conversation

victorandcode
Copy link
Contributor

What

This PR fixes 113. It updates 2 rules: await-async-query and no-await-sync-query

How

  • Selectors were adjusted to match queries inside MemberExpression nodes
  • Some minor refactoring was done to avoid repetition in the new selectors
  • More info in the commit messages

Demo

await-async-query

Before:
Screenshot from 2020-04-18 09-51-28

After
Screenshot from 2020-04-18 09-48-58

no-await-sync-query

Before:
Screenshot from 2020-04-18 10-10-35

After:
Screenshot from 2020-04-18 10-09-56

While running Program:exit(), nodes were tested again unnecessarily for isAwaited and isPromiseResolved
@victorandcode
Copy link
Contributor Author

I seem to be missing one path in the test cases. I'll take a look and update it later.

First, abstract a isQueryUsage function to check if a node should be checked for this rule. Then, add new selector
for queries being called as part of MemberExpression and check their parent against the rule. Finally, use the
queryName prop to make sure the right error message is printed
First, abstract reportError function. Then, create selector for MemberExpression queries.
@victorandcode victorandcode force-pushed the pr/fix-async-checks-when-calling-queries-member-expressions branch from 2759d40 to a7fca52 Compare April 19, 2020 08:50
Copy link
Member

@Belco90 Belco90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow pretty amazing PR. Code pretty clear with nice helpers additions, description of the PR itself really helpful. Thanks for this one!

@Belco90 Belco90 merged commit cedb56b into testing-library:master Apr 19, 2020
@Belco90
Copy link
Member

Belco90 commented Apr 19, 2020

🎉 This PR is included in version 3.0.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Belco90
Copy link
Member

Belco90 commented Apr 19, 2020

@all-contributors please add @victorandcode for code, test and bug

@allcontributors
Copy link
Contributor

@Belco90

I've put up a pull request to add @victorandcode! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

await-async-query not waiting when method is called from wrapper
2 participants