Skip to content

fix: not crash if getSuggestedQuery throw an exception #215

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

marcosvega91
Copy link
Member

fix #214
What: I have fixed the issue

Why: Because it is a bad error

How: if getSuggestedQuery throw an exception the method is skipped

Checklist:

  • Tests
  • Ready to be merged

Comment on lines +114 to +118
try {
return getSuggestedQuery(element, 'get', method);
} catch (e) {
return undefined;
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a big fan of having a try/catch inside a loop. Also, shouldn't this be fixed upstream?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because if other queries don't throw an exception I want to show them

Copy link
Member

@smeijer smeijer Jun 24, 2020

Choose a reason for hiding this comment

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

I understand. And isn't this fixable in @testing-library/dom?

Copy link
Member Author

@marcosvega91 marcosvega91 Jun 24, 2020

Choose a reason for hiding this comment

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

This problem is that it is a new usecase.

We can solve the problem anyway but I think is better to maintain this code to avoid other problem of this kind.

@marcosvega91 marcosvega91 self-assigned this Jun 24, 2020
@smeijer
Copy link
Member

smeijer commented Jun 26, 2020

I'm closing this one, as you've fixed it upstream (testing-library/dom-testing-library@373dbc4).

The dependency has been updated in #220, fixing the root issue.

Thanks for the effort 👍, and the upstream fix 😎

@smeijer smeijer closed this Jun 26, 2020
@marcosvega91
Copy link
Member Author

I suggest you to keep this PR because you can have other exceptions on dom-testing-library and will result in the same error

@smeijer
Copy link
Member

smeijer commented Jun 26, 2020

Do you have concrete examples? Or do you mean as protection for future changes?

@marcosvega91
Copy link
Member Author

only as a protection to avoid that in case of error on dom-testing-library the playground will crash

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

Successfully merging this pull request may close these issues.

Page breaks with compound aria-labelledby example
2 participants