Skip to content

Commit 5c24751

Browse files
author
Luca Forstner
committed
Add tests for happy path without levels in ctor
1 parent 7165018 commit 5c24751

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

packages/integrations/test/captureconsole.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,31 @@ describe('CaptureConsole setup', () => {
179179
expect(mockHub.captureException).toHaveBeenCalledWith(someError);
180180
});
181181

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+
182207
it('should capture message when console logs a non-error object with level set to "error"', () => {
183208
const captureConsoleIntegration = new CaptureConsole({ levels: ['error'] });
184209
captureConsoleIntegration.setupOnce(

0 commit comments

Comments
 (0)