Skip to content

Commit 226e91e

Browse files
committed
Add sentry breadcrumb test
1 parent ea5563b commit 226e91e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { BrowserClient, Breadcrumbs, Hub, flush } from '../../../src';
2+
import { getCurrentHub } from '@sentry/core';
3+
import { getDefaultBrowserClientOptions } from '../helper/browser-client-options';
4+
5+
const hub = new Hub();
6+
7+
jest.mock('@sentry/core', () => {
8+
const original = jest.requireActual('@sentry/core');
9+
return {
10+
...original,
11+
getCurrentHub: () => hub,
12+
};
13+
});
14+
15+
describe('Breadcrumbs', () => {
16+
it('Should add sentry breadcrumb', async () => {
17+
const addBreadcrumb = jest.fn();
18+
hub.addBreadcrumb = addBreadcrumb;
19+
20+
const client = new BrowserClient({
21+
...getDefaultBrowserClientOptions(),
22+
dsn: 'https://username@domain/123',
23+
integrations: [new Breadcrumbs()],
24+
});
25+
26+
getCurrentHub().bindClient(client);
27+
28+
client.captureMessage('test');
29+
await flush(2000);
30+
31+
expect(addBreadcrumb.mock.calls[0][0].category).toEqual('sentry.event');
32+
expect(addBreadcrumb.mock.calls[0][0].message).toEqual('test');
33+
});
34+
});

0 commit comments

Comments
 (0)