@@ -27,7 +27,8 @@ const stopProcessLogging = function (eventName, stopLogging, processHandler) {
2727// Start logging while `process.exit()` is being stubbed
2828export const startExitLogging = function ( opts ) {
2929 stubProcessExit ( )
30- return stopExitLogging . bind ( undefined , startLogging ( opts ) . stopLogging )
30+ const { stopLogging } = startLogging ( opts )
31+ return stopExitLogging . bind ( undefined , stopLogging )
3132}
3233
3334const stopExitLogging = function ( stopLogging ) {
@@ -37,24 +38,15 @@ const stopExitLogging = function (stopLogging) {
3738
3839// Start logging while `setTimeout()` and `process.exit()` are being stubbed
3940export const startClockLogging = function ( opts ) {
40- const clock = stubProcessClock ( )
41+ const clock = fakeTimers . install ( { toFake : [ 'setTimeout' ] } )
42+ stubProcessExit ( )
4143 const { stopLogging } = startLogging ( opts )
4244 const stopLoggingA = stopClockLogging . bind ( undefined , stopLogging , clock )
4345 return { clock, stopLogging : stopLoggingA }
4446}
4547
4648const stopClockLogging = function ( stopLogging , clock ) {
4749 stopLogging ( )
48- unStubProcessClock ( clock )
49- }
50-
51- // Stub `setTimeout()` and `process.exit()`
52- const stubProcessClock = function ( ) {
53- stubProcessExit ( )
54- return fakeTimers . install ( { toFake : [ 'setTimeout' ] } )
55- }
56-
57- const unStubProcessClock = function ( clock ) {
5850 unStubProcessExit ( )
5951 clock . uninstall ( )
6052}
0 commit comments