Skip to content

Commit 28326da

Browse files
committed
add server test
1 parent 7e3b73a commit 28326da

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/nextjs/test/index.server.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { RewriteFrames } from '@sentry/integrations';
22
import * as SentryNode from '@sentry/node';
33
import { getCurrentHub, NodeClient } from '@sentry/node';
44
import { Integration } from '@sentry/types';
5-
import { getGlobalObject } from '@sentry/utils';
5+
import { getGlobalObject, logger, SentryError } from '@sentry/utils';
66
import * as domain from 'domain';
77

88
import { init } from '../src/index.server';
@@ -16,6 +16,7 @@ const global = getGlobalObject();
1616
(global as typeof global & { __rewriteFramesDistDir__: string }).__rewriteFramesDistDir__ = '.next';
1717

1818
const nodeInit = jest.spyOn(SentryNode, 'init');
19+
const logError = jest.spyOn(logger, 'error');
1920

2021
describe('Server init()', () => {
2122
afterEach(() => {
@@ -87,6 +88,18 @@ describe('Server init()', () => {
8788
expect(currentScope._tags.vercel).toBeUndefined();
8889
});
8990

91+
it('adds 404 transaction filter', () => {
92+
init({
93+
dsn: 'https://[email protected]/12312012',
94+
tracesSampleRate: 1.0,
95+
});
96+
97+
const transaction = getCurrentHub().startTransaction({ name: '/404' });
98+
transaction.finish();
99+
100+
expect(logError).toHaveBeenCalledWith(new SentryError('An event processor returned null, will not send event.'));
101+
});
102+
90103
it("initializes both global hub and domain hub when there's an active domain", () => {
91104
const globalHub = getCurrentHub();
92105
const local = domain.create();

0 commit comments

Comments
 (0)