From 654908fa3035283045d4238701bd34199a94d1a1 Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 18 Nov 2021 09:02:06 -0800 Subject: [PATCH] chore: more faithfully mock global.process in test PR-URL: https://github.com/npm/cli/pull/4052 Credit: @isaacs Close: #4052 Reviewed-by: @wraithgar --- test/lib/utils/exit-handler.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/lib/utils/exit-handler.js b/test/lib/utils/exit-handler.js index f74938750237e..adc7c3f4e90fd 100644 --- a/test/lib/utils/exit-handler.js +++ b/test/lib/utils/exit-handler.js @@ -38,13 +38,10 @@ t.before(async () => { npm.config.set('cache', cacheFolder) }) -t.test('bootstrap tap before cutting off process ref', (t) => { - t.ok('ok') - t.end() -}) - // cut off process from script so that it won't quit the test runner -// while trying to run through the myriad of cases +// while trying to run through the myriad of cases. need to make it +// have all the functions signal-exit relies on so that it doesn't +// nerf itself, thinking global.process is broken or gone. const _process = process process = Object.assign( new EventEmitter(), @@ -62,6 +59,9 @@ process = Object.assign( } }, stderr: { write () {} }, hrtime: _process.hrtime, + kill: () => {}, + reallyExit: (code) => process.exit(code), + pid: 123456, } )