-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathindex.client.test.ts
49 lines (42 loc) · 1.26 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
import * as SentryReact from '@sentry/react';
import { describe, vi, it, expect, afterEach, type Mock } from 'vitest';
import { init } from '../src/index.client';
vi.mock('@sentry/react', { spy: true });
const reactInit = SentryReact.init as Mock;
describe('Client init()', () => {
afterEach(() => {
vi.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();
});
});