Skip to content

Commit 1cf0597

Browse files
committed
fix serverless test
1 parent 0b6e01c commit 1cf0597

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

packages/serverless/test/__mocks__/@sentry/node.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const captureException = jest.fn();
4141
export const captureMessage = jest.fn();
4242
export const withScope = jest.fn(cb => cb(fakeScope));
4343
export const flush = jest.fn(() => Promise.resolve());
44+
export const getClient = jest.fn(() => ({}));
4445

4546
export const resetMocks = (): void => {
4647
fakeTransaction.setHttpStatus.mockClear();
@@ -68,4 +69,5 @@ export const resetMocks = (): void => {
6869
captureMessage.mockClear();
6970
withScope.mockClear();
7071
flush.mockClear();
72+
getClient.mockClear();
7173
};

packages/serverless/test/gcpfunction.test.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as domain from 'domain';
22
import * as SentryNode from '@sentry/node';
3-
import type { Event } from '@sentry/types';
3+
import type { Event, Integration } from '@sentry/types';
44

55
import * as Sentry from '../src';
66
import { wrapCloudEventFunction, wrapEventFunction, wrapHttpFunction } from '../src/gcpfunction';
@@ -234,8 +234,6 @@ describe('GCPFunction', () => {
234234
// integration is included in the defaults and the necessary data is stored in `sdkProcessingMetadata`. The
235235
// integration's tests cover testing that it uses that data correctly.
236236
test('wrapHttpFunction request data prereqs', async () => {
237-
expect.assertions(2);
238-
239237
Sentry.GCPFunction.init({});
240238

241239
const handler: HttpFunction = (_req, res) => {
@@ -245,11 +243,10 @@ describe('GCPFunction', () => {
245243

246244
await handleHttp(wrappedHandler);
247245

248-
expect(SentryNode.init).toHaveBeenCalledWith(
249-
expect.objectContaining({
250-
defaultIntegrations: expect.arrayContaining([expect.any(SentryNode.Integrations.RequestData)]),
251-
}),
252-
);
246+
const initOptions = (SentryNode.init as unknown as jest.SpyInstance).mock.calls[0];
247+
const defaultIntegrations = initOptions[0].defaultIntegrations.map((i: Integration) => i.name);
248+
249+
expect(defaultIntegrations).toContain('RequestData');
253250

254251
// @ts-expect-error see "Why @ts-expect-error" note
255252
expect(SentryNode.fakeScope.setSDKProcessingMetadata).toHaveBeenCalledWith({

0 commit comments

Comments
 (0)