-
Notifications
You must be signed in to change notification settings - Fork 458
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
feat(waitFor): add onTimeout which adds DOM output to timeout errors #671
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 2e12261:
|
Codecov Report
@@ Coverage Diff @@
## master #671 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 24 24
Lines 593 595 +2
Branches 148 148
=========================================
+ Hits 593 595 +2
Continue to review full report at Codecov.
|
@@ -112,7 +112,7 @@ describe('asynchronous queries throw on invalid container type', () => { | |||
['findAllByTestId', findAllByTestId], | |||
])('%s', (_queryName, query) => { | |||
const queryOptions = {} | |||
const waitOptions = {timeout: 1} | |||
const waitOptions = {timeout: 1, onTimeout: e => e} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added onTimeout: e => e
to several places in the tests because otherwise the snapshots got formatted really weird and would fail due to formatting issues 🤷♂️
So I added a special test to handle this case specifically and the rest just do nothing to change the error.
@@ -25,6 +26,10 @@ function waitFor( | |||
showOriginalStackTrace = getConfig().showOriginalStackTrace, | |||
stackTraceError, | |||
interval = 50, | |||
onTimeout = error => { | |||
error.message = `${error.message}\n\n${prettyDOM(container)}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason we do this rather than simply calling screen.debug()
here:
- It could be that the
container
isn't bound to the samedocument
asscreen
, so we should use the container given - If we do
screen.debug()
then the DOM output will appear above the error which I think would be confusing.
🎉 This PR is included in version 7.18.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
What: add onTimeout which adds DOM output to timeout errors
Why: Closes #559 (nicer error messages)
How: add the parameter and have it use prettyDOM to attach the nice message to the error
Checklist: