Skip to content

fix: display stack trace and code frame for findBy error #581

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

Merged
merged 1 commit into from
Dec 9, 2020

Conversation

matthieugicquel
Copy link
Contributor

Summary

This fixes #547 with a solution more or less copied from this file in dom-testing-library.

A useful stack trace and codeframe are now shown for findBy failures.

Test plan

Capture d’écran 2020-10-26 à 18 04 53

Note that to get the correct codeframe, the repo running the test must be another that uses this repo as a package, this won't work in the internal tests.

I didn't add any test because I'm not sure assertions on the stack trace make sense...

Contrary to the issue above, the stacktrace was already working with waitFor for me, so while it should improve the situation for waitFor calls too, I can't be sure of it.

Improving the stack trace more

The stack trace still has 2 useless/internal lines, but I suspect to get rid of these, we must:

  • either filter the stack trace string manually
  • or rewrite all the findBy*** helpers to capture the error here

I figured I would open this PR before digging more, since the most important part works :)

Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

Thanks!

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.

Show stack-trace for failed findBy or waitFor
3 participants