feat: add tests for node/heart.ts#5122
Conversation
|
✨ code-server docs for PR #5122 is ready! It will be updated on every commit.
|
Codecov Report
@@ Coverage Diff @@
## main #5122 +/- ##
==========================================
+ Coverage 71.33% 71.73% +0.39%
==========================================
Files 30 30
Lines 1685 1684 -1
Branches 374 374
==========================================
+ Hits 1202 1208 +6
+ Misses 413 407 -6
+ Partials 70 69 -1
Continue to review full report at Codecov.
|
436fca7 to
0e4c062
Compare
To make it easier to test, I extract heartbeatTimer into it's own function.
5024c67 to
3934ca3
Compare
| // HACK@jsjoeio - beat has some async logic but is not an async method | ||
| // Therefore, we have to create an artificial wait in order to make sure | ||
| // all async code has completed before asserting |
There was a problem hiding this comment.
This looks good to me for now. Maybe long-term we can make beat async, at least up to the file write.
There was a problem hiding this comment.
Yes! I briefly looked into it for this PR but since it happens in a request, I wasn't sure if changing it here to make the handler async would causes so I didn't.
There was a problem hiding this comment.
Ah yeah I think the move would be to only await in tests. For other uses we can leave them as-is (since we do not want to delay the request to write to the heartbeat file).
There was a problem hiding this comment.
Ah gotcha! I did use await when I was first writing the tests but TS said it would have no effect lol but I guess that's because it couldn't infer the callback logic? I'm not sure lol
There was a problem hiding this comment.
Ahh yup we would need to make beat async first and then add the await in the tests.
There was a problem hiding this comment.
But I think the current workaround is chill
Co-authored-by: Asher <ash@coder.com>
This PR adds tests to increase coverage for
src/node/heart.ts.Related to #5121