-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathindex.client.test.ts
53 lines (46 loc) · 1.28 KB
/
index.client.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import * as SentryReact from '@sentry/react';
import { init } from '../src/index.client';
jest.mock('@sentry/react', () => {
return {
__esModule: true,
...jest.requireActual('@sentry/react'),
};
});
const reactInit = jest.spyOn(SentryReact, 'init');
describe('Client init()', () => {
afterEach(() => {
jest.clearAllMocks();
SentryReact.getGlobalScope().clear();
SentryReact.getIsolationScope().clear();
SentryReact.getCurrentScope().clear();
SentryReact.getCurrentScope().setClient(undefined);
});
it('inits the React SDK', () => {
expect(reactInit).toHaveBeenCalledTimes(0);
init({});
expect(reactInit).toHaveBeenCalledTimes(1);
expect(reactInit).toHaveBeenCalledWith(
expect.objectContaining({
_metadata: {
sdk: {
name: 'sentry.javascript.remix',
version: expect.any(String),
packages: [
{
name: 'npm:@sentry/remix',
version: expect.any(String),
},
{
name: 'npm:@sentry/react',
version: expect.any(String),
},
],
},
},
}),
);
});
it('returns client from init', () => {
expect(init({})).not.toBeUndefined();
});
});