-
Notifications
You must be signed in to change notification settings - Fork 6.3k
feat: add test for onLine throw error #4542
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
Conversation
✨ Coder.com for PR #4542 deployed! It will be updated on every commit.
- Host: https://codercom-flm35enk4-codercom.vercel.app/docs/code-server
- Last deploy status: success
- Commit: d4ba9bb
- Workflow status: https://github.com/cdr/code-server/actions/runs/1491872274
Codecov Report
@@ Coverage Diff @@ ## main #4542 +/- ## ========================================== + Coverage 65.38% 65.44% +0.06% ========================================== Files 30 30 Lines 1664 1664 Branches 335 335 ========================================== + Hits 1088 1089 +1 + Misses 488 487 -1 Partials 88 88
Continue to review full report at Codecov.
|
test/unit/node/util.test.ts
Outdated
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.
According to the docs, it doesn't seem like I should have to do this but no matter what values I pass in the array to stdio
it seems like proc.stdout
is always set? I would love a second opinion here cc @vapurrmaid @bryphe-coder
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 think you might need different settings for cp.spawn
to exercise this - checking
@bryphe-coder
bryphe-coder
Nov 22, 2021
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.
If I use the stdio
flag 'ignore'
, it seems to work as you expect (in order to exercise the code under test):
const proc = cp.spawn("node", [], {
stdio: 'ignore'
})
@bryphe-coder
bryphe-coder
Nov 22, 2021
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.
At least, tested this out in the NodeJS console:
image
@bryphe-coder
bryphe-coder
Nov 22, 2021
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.
Some useful docs around the various settings for options.stdio
here: https://nodejs.org/api/child_process.html#optionsstdio
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.
Oh wow! Nice work 🙌 Okay I'll try that locally and see if it works for me as well.
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.
If I use the
stdio
flag'ignore'
, it seems to work as you expect (in order to exercise the code under test):const proc = cp.spawn("node", [], { stdio: 'ignore' })
That worked!!!
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 one is better than my suggestion - glad it worked!
@bryphe-coder
bryphe-coder
left a comment
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.
Curious if make the change to use stdio: [null]
-> stdio: 'ignore'
works for you, in order to remove the manual setting of proc.stdout
.
Otherwise, LGTM 👍
test/unit/node/util.test.ts
Outdated
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.
Does
stdio: [0, "empty"]
work?
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.
Looks like TS doesn't like this but stdio: 'ignore'
worked!
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.
Nice!
6c3105a
to
afa5200
Compare
afa5200
to
d4ba9bb
Compare
Uh oh!
There was an error while loading. Please reload this page.
This PR adds an additional test for the
onLine
util function to cover the scenario where the child.Process passed to the function is missing thestdout
method. This adds code coverage for this line.Screenshot
image
References
stdio
- Node.js docsFixes N/A
#TestingMondays
Blocked by #4543