-
Notifications
You must be signed in to change notification settings - Fork 633
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(async/unstable): add waitFor
function to wait for condition to be true (#6213)
#6230
base: main
Are you sure you want to change the base?
Conversation
async/unstable_wait_for_test.ts
Outdated
|
||
Deno.test("waitFor() throws DOMException on timeout", async () => { | ||
let flag = false; | ||
setTimeout(() => flag = true, 1000); |
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.
This timer needs to be cleared at the end of the test case to avoid op leak error
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.
Will do, makes sense. I do not know why I did not get the leak when running locally.
"Signal timed out.", | ||
); | ||
assertAlmostEquals(Date.now() - start, 100, 10); | ||
assertEquals(error.name, "TimeoutError"); |
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.
👍
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6230 +/- ##
=======================================
Coverage 96.52% 96.52%
=======================================
Files 534 535 +1
Lines 40976 40996 +20
Branches 6134 6135 +1
=======================================
+ Hits 39551 39573 +22
+ Misses 1383 1381 -2
Partials 42 42 ☔ View full report in Codecov by Sentry. |
I just remembered another rule about designing this type of function. We tend to put the function-type argument at the last of parameters. The examples are Deno.serve, Deno.test, Deno.addSignalListener. (It is noted in our style guide)
What do you think about changing this to |
Sure, makes sense, let me give it a try. I was following the deadline layout which has the |
Submitting PR to contribute
waitFor
function (see #6213). Fixed small type in delay tests as well.