|
1 | | -import { addGlobalEventProcessor, init as browserInitRaw, SDK_VERSION } from '@sentry/browser'; |
| 1 | +import { addGlobalEventProcessor, init as browserInit, SDK_VERSION } from '@sentry/browser'; |
2 | 2 | import { EventProcessor } from '@sentry/types'; |
3 | 3 |
|
4 | 4 | import { detectAndReportSvelteKit, init as svelteInit, isSvelteKitApp } from '../src/sdk'; |
5 | 5 |
|
6 | | -const browserInit = browserInitRaw as jest.Mock; |
7 | | -const addGlobalEventProcessorFunction = addGlobalEventProcessor as jest.Mock; |
8 | 6 | let passedEventProcessor: EventProcessor | undefined; |
9 | | -addGlobalEventProcessorFunction.mockImplementation(proc => { |
10 | | - passedEventProcessor = proc; |
11 | | -}); |
12 | 7 |
|
13 | | -jest.mock('@sentry/browser'); |
| 8 | +jest.mock('@sentry/browser', () => { |
| 9 | + const actual = jest.requireActual('@sentry/browser'); |
| 10 | + return { |
| 11 | + ...actual, |
| 12 | + init: jest.fn().mockImplementation(actual.init), |
| 13 | + addGlobalEventProcessor: jest.fn().mockImplementation(proc => { |
| 14 | + passedEventProcessor = proc; |
| 15 | + }), |
| 16 | + }; |
| 17 | +}); |
14 | 18 |
|
15 | 19 | describe('Initialize Svelte SDk', () => { |
16 | 20 | afterAll(() => { |
@@ -48,7 +52,7 @@ describe('detectAndReportSvelteKit()', () => { |
48 | 52 | it('registers a global event processor', async () => { |
49 | 53 | detectAndReportSvelteKit(); |
50 | 54 |
|
51 | | - expect(addGlobalEventProcessorFunction).toHaveBeenCalledTimes(1); |
| 55 | + expect(addGlobalEventProcessor).toHaveBeenCalledTimes(1); |
52 | 56 | expect(passedEventProcessor?.id).toEqual('svelteKitProcessor'); |
53 | 57 | }); |
54 | 58 |
|
|
0 commit comments