-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathconsole.test.ts
39 lines (33 loc) · 1.04 KB
/
console.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import * as SentryCore from '@sentry/core';
import { resetInstrumentationHandlers } from '@sentry/core';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { getClient } from '../../src';
import type { NodeClient } from '../../src';
import { consoleIntegration } from '../../src/integrations/console';
const addBreadcrumbSpy = vi.spyOn(SentryCore, 'addBreadcrumb');
vi.spyOn(console, 'log').mockImplementation(() => {
// noop so that we don't spam the logs
});
afterEach(() => {
vi.clearAllMocks();
resetInstrumentationHandlers();
});
describe('Console integration', () => {
it('should add a breadcrumb on console.log', () => {
consoleIntegration().setup?.(getClient() as NodeClient);
// eslint-disable-next-line no-console
console.log('test');
expect(addBreadcrumbSpy).toHaveBeenCalledTimes(1);
expect(addBreadcrumbSpy).toHaveBeenCalledWith(
{
category: 'console',
level: 'log',
message: 'test',
},
{
input: ['test'],
level: 'log',
},
);
});
});