Skip to content

Commit 35d6508

Browse files
author
Luca Forstner
committed
Add test with empty levels array
1 parent 5c24751 commit 35d6508

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/integrations/test/captureconsole.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,26 @@ describe('CaptureConsole setup', () => {
6464
expect(global.console.table).toBe(originalConsole.table);
6565
});
6666

67+
it('should not wrap any functions with an empty levels option', () => {
68+
const captureConsoleIntegration = new CaptureConsole({ levels: [] });
69+
captureConsoleIntegration.setupOnce(
70+
() => undefined,
71+
() => getMockHubWithIntegration(captureConsoleIntegration) as any,
72+
);
73+
74+
// expect the default set of console levels not to have been monkey patched
75+
expect(global.console.debug).toBe(originalConsole.debug);
76+
expect(global.console.info).toBe(originalConsole.info);
77+
expect(global.console.warn).toBe(originalConsole.warn);
78+
expect(global.console.error).toBe(originalConsole.error);
79+
expect(global.console.log).toBe(originalConsole.log);
80+
expect(global.console.assert).toBe(originalConsole.assert);
81+
82+
// expect no message to be captured with console.log
83+
global.console.log('some message');
84+
expect(mockHub.captureMessage).not.toHaveBeenCalled();
85+
});
86+
6787
it('setup should fail gracefully when console is not available', () => {
6888
const consoleRef = global.console;
6989
// remove console

0 commit comments

Comments
 (0)