File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
packages/integrations/test Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,31 @@ describe('CaptureConsole setup', () => {
179
179
expect ( mockHub . captureException ) . toHaveBeenCalledWith ( someError ) ;
180
180
} ) ;
181
181
182
+ it ( 'should capture exception on `console.error` when no levels are provided in constructor' , ( ) => {
183
+ const captureConsoleIntegration = new CaptureConsole ( ) ;
184
+ captureConsoleIntegration . setupOnce (
185
+ ( ) => undefined ,
186
+ ( ) => getMockHubWithIntegration ( captureConsoleIntegration ) as any ,
187
+ ) ;
188
+
189
+ const someError = new Error ( 'some error' ) ;
190
+ global . console . error ( someError ) ;
191
+
192
+ expect ( mockHub . captureException ) . toHaveBeenCalledWith ( someError ) ;
193
+ } ) ;
194
+
195
+ it ( 'should capture message on `console.log` when no levels are provided in constructor' , ( ) => {
196
+ const captureConsoleIntegration = new CaptureConsole ( ) ;
197
+ captureConsoleIntegration . setupOnce (
198
+ ( ) => undefined ,
199
+ ( ) => getMockHubWithIntegration ( captureConsoleIntegration ) as any ,
200
+ ) ;
201
+
202
+ global . console . error ( 'some message' ) ;
203
+
204
+ expect ( mockHub . captureMessage ) . toHaveBeenCalledWith ( 'some message' ) ;
205
+ } ) ;
206
+
182
207
it ( 'should capture message when console logs a non-error object with level set to "error"' , ( ) => {
183
208
const captureConsoleIntegration = new CaptureConsole ( { levels : [ 'error' ] } ) ;
184
209
captureConsoleIntegration . setupOnce (
You can’t perform that action at this time.
0 commit comments