Skip to content

Commit 9acd235

Browse files
committed
simplify tests
1 parent f00f635 commit 9acd235

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

packages/nextjs/test/utils/withSentry.test.ts

+5-14
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
11
import { Hub, makeMain } from '@sentry/hub';
2-
import { NodeClient } from '@sentry/node';
2+
import * as Sentry from '@sentry/node';
33
import { logger } from '@sentry/utils';
44
import { NextApiRequest } from 'next';
55

66
import { AugmentedNextApiResponse, withSentry } from '../../src/utils/withSentry';
77

88
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');
2110

2211
describe('withSentry', () => {
2312
it('flushes events before rethrowing error', async () => {
2413
const hub = new Hub(
25-
new NodeClient({ dsn: 'https://[email protected]/12312012' }),
14+
new Sentry.NodeClient({
15+
dsn: 'https://[email protected]/12312012',
16+
}),
2617
);
2718
makeMain(hub);
2819
const req = { url: 'http://dogs.are.great' } as NextApiRequest;

0 commit comments

Comments
 (0)