File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -447,6 +447,28 @@ describe("onLine", () => {
447
447
448
448
expect ( await received ) . toEqual ( expected )
449
449
} )
450
+
451
+ describe ( "used with a process missing stdout " , ( ) => {
452
+ it ( "should throw an error" , async ( ) => {
453
+ // Initialize a process that does not have stdout.
454
+ // "If the child was spawned with stdio set to anything
455
+ // other than 'pipe', then subprocess.stdout will be null."
456
+ // Source: https://stackoverflow.com/a/46024006/3015595
457
+ // Other source: https://nodejs.org/api/child_process.html#child_process_subprocess_stdout
458
+ // NOTE@jsjoeio - I'm not sure if this actually happens though
459
+ // which is why I have to set proc.stdout = null
460
+ // a couple lines below.
461
+ const proc = cp . spawn ( "node" , [ ] , {
462
+ stdio : "ignore" ,
463
+ } )
464
+ const mockCallback = jest . fn ( )
465
+
466
+ expect ( ( ) => util . onLine ( proc , mockCallback ) ) . toThrowError ( / s t d o u t / )
467
+
468
+ // Cleanup
469
+ proc ?. kill ( )
470
+ } )
471
+ } )
450
472
} )
451
473
452
474
describe ( "escapeHtml" , ( ) => {
You can’t perform that action at this time.
0 commit comments