-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathsdk.test.ts
47 lines (37 loc) · 1.35 KB
/
sdk.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
import { afterEach, describe, expect, it, vi } from 'vitest';
import * as SentryBrowser from '@sentry/browser';
import { SDK_VERSION, getCurrentScope, getGlobalScope, getIsolationScope } from '@sentry/browser';
import { init as reactRouterInit } from '../../src/client';
const browserInit = vi.spyOn(SentryBrowser, 'init');
describe('React Router client SDK', () => {
describe('init', () => {
afterEach(() => {
vi.clearAllMocks();
getGlobalScope().clear();
getIsolationScope().clear();
getCurrentScope().clear();
getCurrentScope().setClient(undefined);
});
it('adds React Router metadata to the SDK options', () => {
expect(browserInit).not.toHaveBeenCalled();
reactRouterInit({});
const expectedMetadata = {
_metadata: {
sdk: {
name: 'sentry.javascript.react-router',
version: SDK_VERSION,
packages: [
{ name: 'npm:@sentry/react-router', version: SDK_VERSION },
{ name: 'npm:@sentry/browser', version: SDK_VERSION },
],
},
},
};
expect(browserInit).toHaveBeenCalledTimes(1);
expect(browserInit).toHaveBeenCalledWith(expect.objectContaining(expectedMetadata));
});
it('returns client from init', () => {
expect(reactRouterInit({})).not.toBeUndefined();
});
});
});