@@ -25,7 +25,7 @@ describe('subscribeProcessExit', () => {
2525 } ) ;
2626
2727 it ( 'should install event listeners for all expected events' , ( ) => {
28- expect ( ( ) => subscribeProcessExit ( { onError, onExit } ) ) . not . toThrowError ( ) ;
28+ expect ( ( ) => subscribeProcessExit ( { onError, onExit } ) ) . not . toThrow ( ) ;
2929
3030 expect ( processOnSpy ) . toHaveBeenCalledWith (
3131 'uncaughtException' ,
@@ -42,91 +42,86 @@ describe('subscribeProcessExit', () => {
4242 } ) ;
4343
4444 it ( 'should call onError with error and kind for uncaughtException' , ( ) => {
45- expect ( ( ) => subscribeProcessExit ( { onError } ) ) . not . toThrowError ( ) ;
45+ expect ( ( ) => subscribeProcessExit ( { onError } ) ) . not . toThrow ( ) ;
4646
4747 const testError = new Error ( 'Test uncaught exception' ) ;
4848
4949 ( process as any ) . emit ( 'uncaughtException' , testError ) ;
5050
51- expect ( onError ) . toHaveBeenCalledExactlyOnceWith (
52- testError ,
53- 'uncaughtException' ,
54- ) ;
51+ expect ( onError ) . toHaveBeenCalledWith ( testError , 'uncaughtException' ) ;
52+ expect ( onError ) . toHaveBeenCalledOnce ( ) ;
5553 expect ( onExit ) . not . toHaveBeenCalled ( ) ;
5654 } ) ;
5755
5856 it ( 'should call onError with reason and kind for unhandledRejection' , ( ) => {
59- expect ( ( ) => subscribeProcessExit ( { onError } ) ) . not . toThrowError ( ) ;
57+ expect ( ( ) => subscribeProcessExit ( { onError } ) ) . not . toThrow ( ) ;
6058
6159 const testReason = 'Test unhandled rejection' ;
6260
6361 ( process as any ) . emit ( 'unhandledRejection' , testReason ) ;
6462
65- expect ( onError ) . toHaveBeenCalledExactlyOnceWith (
66- testReason ,
67- 'unhandledRejection' ,
68- ) ;
63+ expect ( onError ) . toHaveBeenCalledWith ( testReason , 'unhandledRejection' ) ;
64+ expect ( onError ) . toHaveBeenCalledOnce ( ) ;
6965 expect ( onExit ) . not . toHaveBeenCalled ( ) ;
7066 } ) ;
7167
7268 it ( 'should call onExit and exit with code 0 for SIGINT' , ( ) => {
73- expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrowError ( ) ;
69+ expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrow ( ) ;
7470
7571 ( process as any ) . emit ( 'SIGINT' ) ;
7672
77- expect ( onExit ) . toHaveBeenCalledExactlyOnceWith ( SIGNAL_EXIT_CODES ( ) . SIGINT , {
73+ expect ( onExit ) . toHaveBeenCalledOnce ( ) ;
74+ expect ( onExit ) . toHaveBeenCalledWith ( SIGNAL_EXIT_CODES ( ) . SIGINT , {
7875 kind : 'signal' ,
7976 signal : 'SIGINT' ,
8077 } ) ;
8178 expect ( onError ) . not . toHaveBeenCalled ( ) ;
8279 } ) ;
8380
8481 it ( 'should call onExit and exit with code 0 for SIGTERM' , ( ) => {
85- expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrowError ( ) ;
82+ expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrow ( ) ;
8683
8784 ( process as any ) . emit ( 'SIGTERM' ) ;
8885
89- expect ( onExit ) . toHaveBeenCalledExactlyOnceWith (
90- SIGNAL_EXIT_CODES ( ) . SIGTERM ,
91- {
92- kind : 'signal' ,
93- signal : 'SIGTERM' ,
94- } ,
95- ) ;
86+ expect ( onExit ) . toHaveBeenCalledOnce ( ) ;
87+ expect ( onExit ) . toHaveBeenCalledWith ( SIGNAL_EXIT_CODES ( ) . SIGTERM , {
88+ kind : 'signal' ,
89+ signal : 'SIGTERM' ,
90+ } ) ;
9691 expect ( onError ) . not . toHaveBeenCalled ( ) ;
9792 } ) ;
9893
9994 it ( 'should call onExit and exit with code 0 for SIGQUIT' , ( ) => {
100- expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrowError ( ) ;
95+ expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrow ( ) ;
10196
10297 ( process as any ) . emit ( 'SIGQUIT' ) ;
10398
104- expect ( onExit ) . toHaveBeenCalledExactlyOnceWith (
105- SIGNAL_EXIT_CODES ( ) . SIGQUIT ,
106- {
107- kind : 'signal' ,
108- signal : 'SIGQUIT' ,
109- } ,
110- ) ;
99+ expect ( onExit ) . toHaveBeenCalledOnce ( ) ;
100+ expect ( onExit ) . toHaveBeenCalledWith ( SIGNAL_EXIT_CODES ( ) . SIGQUIT , {
101+ kind : 'signal' ,
102+ signal : 'SIGQUIT' ,
103+ } ) ;
111104 expect ( onError ) . not . toHaveBeenCalled ( ) ;
112105 } ) ;
113106
114107 it ( 'should call onExit for successful process termination with exit code 0' , ( ) => {
115- expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrowError ( ) ;
108+ expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrow ( ) ;
116109
117110 ( process as any ) . emit ( 'exit' , 0 ) ;
118111
119- expect ( onExit ) . toHaveBeenCalledExactlyOnceWith ( 0 , { kind : 'exit' } ) ;
112+ expect ( onExit ) . toHaveBeenCalledOnce ( ) ;
113+ expect ( onExit ) . toHaveBeenCalledWith ( 0 , { kind : 'exit' } ) ;
120114 expect ( onError ) . not . toHaveBeenCalled ( ) ;
121115 expect ( processExitSpy ) . not . toHaveBeenCalled ( ) ;
122116 } ) ;
123117
124118 it ( 'should call onExit for failed process termination with exit code 1' , ( ) => {
125- expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrowError ( ) ;
119+ expect ( ( ) => subscribeProcessExit ( { onExit } ) ) . not . toThrow ( ) ;
126120
127121 ( process as any ) . emit ( 'exit' , 1 ) ;
128122
129- expect ( onExit ) . toHaveBeenCalledExactlyOnceWith ( 1 , { kind : 'exit' } ) ;
123+ expect ( onExit ) . toHaveBeenCalledOnce ( ) ;
124+ expect ( onExit ) . toHaveBeenCalledWith ( 1 , { kind : 'exit' } ) ;
130125 expect ( onError ) . not . toHaveBeenCalled ( ) ;
131126 expect ( processExitSpy ) . not . toHaveBeenCalled ( ) ;
132127 } ) ;
0 commit comments