@@ -36,27 +36,25 @@ it('tracks Promise rejections when using `promise` polyfill', () => {
3636 } ) ;
3737} ) ;
3838
39- it . each ( [ new Error ( ) , "Couldn't fetch data" ] ) (
40- 'reports unhandled Promise rejections in release mode' ,
41- ( rejection ) => {
42- const mockDev = mockDevMode ( false ) ;
43- const consoleWarnSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
39+ it ( 'reports unhandled Promise rejections in release mode' , ( ) => {
40+ const mockDev = mockDevMode ( false ) ;
41+ const consoleWarnSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
4442
45- const id = 123 ;
43+ const rejection = new Error ( 'something went wrong' ) ;
44+ const id = 123 ;
4645
47- // Simulate an immediate unhandled promise rejection
48- mocked ( tracking . enable ) . mockImplementationOnce ( ( options ) => {
49- options ?. onUnhandled ?.( id , rejection ) ;
50- } ) ;
46+ // Simulate an immediate unhandled promise rejection
47+ mocked ( tracking . enable ) . mockImplementationOnce ( ( options ) => {
48+ options ?. onUnhandled ?.( id , rejection ) ;
49+ } ) ;
5150
52- captureUnhandledRejections ( ) ;
51+ captureUnhandledRejections ( ) ;
5352
54- expect ( NativeCrashReporting . sendHandledJSCrash ) . toBeCalledTimes ( 1 ) ;
53+ expect ( NativeCrashReporting . sendHandledJSCrash ) . toBeCalledTimes ( 1 ) ;
5554
56- mockDev . mockRestore ( ) ;
57- consoleWarnSpy . mockRestore ( ) ;
58- } ,
59- ) ;
55+ mockDev . mockRestore ( ) ;
56+ consoleWarnSpy . mockRestore ( ) ;
57+ } ) ;
6058
6159it ( 'does not report unhandled Promise rejections in dev mode' , ( ) => {
6260 const mockDev = mockDevMode ( true ) ;
@@ -77,3 +75,23 @@ it('does not report unhandled Promise rejections in dev mode', () => {
7775 mockDev . mockRestore ( ) ;
7876 consoleWarnSpy . mockRestore ( ) ;
7977} ) ;
78+
79+ it ( 'does not report non-error unhandled Promise rejections' , ( ) => {
80+ const mockDev = mockDevMode ( true ) ;
81+ const consoleWarnSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
82+
83+ const id = 123 ;
84+ const rejection = 'something went wrong' ;
85+
86+ // Simulate an immediate unhandled promise rejection
87+ mocked ( tracking . enable ) . mockImplementationOnce ( ( options ) => {
88+ options ?. onUnhandled ?.( id , rejection ) ;
89+ } ) ;
90+
91+ captureUnhandledRejections ( ) ;
92+
93+ expect ( NativeCrashReporting . sendHandledJSCrash ) . not . toBeCalled ( ) ;
94+
95+ mockDev . mockRestore ( ) ;
96+ consoleWarnSpy . mockRestore ( ) ;
97+ } ) ;
0 commit comments