Show stack-trace for failed findBy or waitFor
See original GitHub issueDescribe the Feature
Currently, if your test has a lot of await findBy
, if one of them fails, it’s hard to know which one from the error message.
It’d be great if the error message would include the line of the findBy
that fails, the same way it does for getBy
with findBy
:
● Testing react navigation › clicking on one item takes you to the details screen
No instances found
with getBy
:
● Testing react navigation › clicking on one item takes you to the details screen
No instances found
24 | fireEvent(toClick, 'press');
25 | const newHeader = await findByText('Showing details for 5');
> 26 | const newBody = getByText('the number you have chosen is 6');
Possible Implementations
I’d be happy to look into the code and see if I can provide a PR if nobody is currently working on this.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (8 by maintainers)
Top Results From Across the Web
reactjs - Why does a test fail when using findBy but succeed ...
By the look of it, seems fine (except for using the find query inside waitFor). Try adding logs at every step of the...
Read more >[Solved]-Why does a test fail when using findBy but succeed ...
I think its better to use waitFor than findBy which is in my opinion is more self explanatory that it is async/needs to...
Read more >Async Methods - Testing Library
findBy methods are a combination of getBy queries and waitFor . They accept the waitFor options as the last argument (e.g. await screen....
Read more >Using React Testing Library - Sentry Developer Documentation
We are in the process of converting our tests from Enzyme to React Testing Library. In this guide, you'll find tips to follow...
Read more >ERROR-STACK-TRACE attribute - Progress Documentation
This attribute controls whether or not the CallStack property on error objects can be used. Because the CallStack feature is for debugging and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
None that I know of
@kevinbror KCD also recommends using only single assertion for
waitFor
queries in his Common mistakes with RTL article. The reasoning is as follows: