|
1 | 1 | import { Hub, makeMain } from '@sentry/hub';
|
2 |
| -import { NodeClient } from '@sentry/node'; |
| 2 | +import * as Sentry from '@sentry/node'; |
3 | 3 | import { logger } from '@sentry/utils';
|
4 | 4 | import { NextApiRequest } from 'next';
|
5 | 5 |
|
6 | 6 | import { AugmentedNextApiResponse, withSentry } from '../../src/utils/withSentry';
|
7 | 7 |
|
8 | 8 | const loggerSpy = jest.spyOn(logger, 'log');
|
9 |
| -let captureExceptionSpy: jest.Mock; |
10 |
| - |
11 |
| -// Prevent captureException from creating and leaving an open handle after test already finished |
12 |
| -jest.mock('@sentry/node', () => { |
13 |
| - const actual = jest.requireActual('@sentry/node'); |
14 |
| - // Mocks are hoisted, thus we need to instentiate a variable here |
15 |
| - captureExceptionSpy = jest.fn(); |
16 |
| - return { |
17 |
| - ...actual, |
18 |
| - captureException: captureExceptionSpy, |
19 |
| - }; |
20 |
| -}); |
| 9 | +const captureExceptionSpy = jest.spyOn(Sentry, 'captureException'); |
21 | 10 |
|
22 | 11 | describe('withSentry', () => {
|
23 | 12 | it('flushes events before rethrowing error', async () => {
|
24 | 13 | const hub = new Hub(
|
25 |
| - new NodeClient({ dsn: 'https://[email protected]/12312012' }), |
| 14 | + new Sentry.NodeClient({ |
| 15 | + dsn: 'https://[email protected]/12312012', |
| 16 | + }), |
26 | 17 | );
|
27 | 18 | makeMain(hub);
|
28 | 19 | const req = { url: 'http://dogs.are.great' } as NextApiRequest;
|
|
0 commit comments