-
Notifications
You must be signed in to change notification settings - Fork 2
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
Handle synchronous TestFailure within async fn body #40
Handle synchronous TestFailure within async fn body #40
Conversation
264b749
to
4c68ac2
Compare
Security InsightsNo security relevant content was detected by automated scans. Action Items
Questions or Comments? Reach out on Slack: #support-infosec. |
4c68ac2
to
556698d
Compare
Align waitFor implementation more closely with JS implementation
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.
+10
semver +1
@Workiva/release-management-pp |
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.
+1 from RM
Motivation
@josephnaberhaus-wk pointed out that when the
async
modifier is added to thewaitFor
callback, anyexpect()
within the callback that fails will causewaitFor
to throw immediately instead of continuing to call the callback on an interval.Essentially - the issue is that currently, the first test will fail immediately instead of waiting for
numRuns
to get to5
, whereas the second test will pass since it's notasync
.@greglittlefield-wf @joebingham-wk @sydneyjodon-wk I am unsure if handling synchronous failures like this is desired behavior, but I am putting up this PR since I was able to get something working that seems to also preserve the existing behaviors of waiting for things like one of RTL's async matchers (
findBy*
).Changes
Only call
onDone()
when the error thrown from the async function is not aTestFailure
. If it is aTestFailure
, store that failure as thelastError
like we do when an error is thrown from a synchronous callback, and keep trying the callback until a timeout occurs.These changes make it so that both of the test cases shown above will pass as expected.
Release Notes
Add support for synchronous test failures within an asynchronous callback in the
waitFor
utility.