Skip to content

Commit 2cdd28e

Browse files
committed
Update deprecated methods
1 parent 979d8ae commit 2cdd28e

File tree

24 files changed

+200
-199
lines changed

24 files changed

+200
-199
lines changed

packages/angular/test/errorhandler.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ describe('SentryErrorHandler', () => {
534534
// this simulates the afterSend hook being called
535535
client.cb({ event_id: 'foobar' });
536536

537-
expect(showReportDialogSpy).toBeCalledTimes(1);
537+
expect(showReportDialogSpy).toHaveBeenCalledTimes(1);
538538
});
539539

540540
it('by just calling `showReportDialog` if hooks are not available', () => {
@@ -543,7 +543,7 @@ describe('SentryErrorHandler', () => {
543543
const errorHandler = createErrorHandler({ showDialog: true });
544544
errorHandler.handleError(new Error('test'));
545545

546-
expect(showReportDialogSpy).toBeCalledTimes(1);
546+
expect(showReportDialogSpy).toHaveBeenCalledTimes(1);
547547
});
548548
});
549549

packages/aws-serverless/test/sdk.test.ts

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,18 @@ const fakeCallback: Callback = (err, result) => {
8181
};
8282

8383
function expectScopeSettings() {
84-
expect(mockScope.addEventProcessor).toBeCalledTimes(1);
84+
expect(mockScope.addEventProcessor).toHaveBeenCalledTimes(1);
8585
// Test than an event processor to add `transaction` is registered for the scope
8686
const eventProcessor = mockScope.addEventProcessor.mock.calls[0][0];
8787
const event: Event = {};
8888
eventProcessor(event);
8989
expect(event).toEqual({ transaction: 'functionName' });
9090

91-
expect(mockScope.setTag).toBeCalledWith('server_name', expect.anything());
91+
expect(mockScope.setTag).toHaveBeenCalledWith('server_name', expect.anything());
9292

93-
expect(mockScope.setTag).toBeCalledWith('url', 'awslambda:///functionName');
93+
expect(mockScope.setTag).toHaveBeenCalledWith('url', 'awslambda:///functionName');
9494

95-
expect(mockScope.setContext).toBeCalledWith(
95+
expect(mockScope.setContext).toHaveBeenCalledWith(
9696
'aws.lambda',
9797
expect.objectContaining({
9898
aws_request_id: 'awsRequestId',
@@ -103,7 +103,7 @@ function expectScopeSettings() {
103103
}),
104104
);
105105

106-
expect(mockScope.setContext).toBeCalledWith(
106+
expect(mockScope.setContext).toHaveBeenCalledWith(
107107
'aws.cloudwatch.logs',
108108
expect.objectContaining({
109109
log_group: 'logGroupName',
@@ -129,7 +129,7 @@ describe('AWSLambda', () => {
129129
const wrappedHandler = wrapHandler(handler, { flushTimeout: 1337 });
130130

131131
await wrappedHandler(fakeEvent, fakeContext, fakeCallback);
132-
expect(mockFlush).toBeCalledWith(1337);
132+
expect(mockFlush).toHaveBeenCalledWith(1337);
133133
});
134134

135135
test('captureTimeoutWarning enabled (default)', async () => {
@@ -141,9 +141,9 @@ describe('AWSLambda', () => {
141141
const wrappedHandler = wrapHandler(handler);
142142
await wrappedHandler(fakeEvent, fakeContext, fakeCallback);
143143

144-
expect(mockWithScope).toBeCalledTimes(1);
145-
expect(mockCaptureMessage).toBeCalled();
146-
expect(mockScope.setTag).toBeCalledWith('timeout', '1s');
144+
expect(mockWithScope).toHaveBeenCalledTimes(1);
145+
expect(mockCaptureMessage).toHaveBeenCalled();
146+
expect(mockScope.setTag).toHaveBeenCalledWith('timeout', '1s');
147147
});
148148

149149
test('captureTimeoutWarning disabled', async () => {
@@ -157,9 +157,9 @@ describe('AWSLambda', () => {
157157
});
158158
await wrappedHandler(fakeEvent, fakeContext, fakeCallback);
159159

160-
expect(mockWithScope).toBeCalledTimes(0);
161-
expect(mockCaptureMessage).not.toBeCalled();
162-
expect(mockScope.setTag).not.toBeCalledWith('timeout', '1s');
160+
expect(mockWithScope).toHaveBeenCalledTimes(0);
161+
expect(mockCaptureMessage).not.toHaveBeenCalled();
162+
expect(mockScope.setTag).not.toHaveBeenCalledWith('timeout', '1s');
163163
});
164164

165165
test('captureTimeoutWarning with configured timeoutWarningLimit', async () => {
@@ -188,15 +188,15 @@ describe('AWSLambda', () => {
188188
fakeCallback,
189189
);
190190

191-
expect(mockCaptureMessage).toBeCalled();
192-
expect(mockScope.setTag).toBeCalledWith('timeout', '1m40s');
191+
expect(mockCaptureMessage).toHaveBeenCalled();
192+
expect(mockScope.setTag).toHaveBeenCalledWith('timeout', '1m40s');
193193
});
194194

195195
test('captureAllSettledReasons disabled (default)', async () => {
196196
const handler = () => Promise.resolve([{ status: 'rejected', reason: new Error() }]);
197197
const wrappedHandler = wrapHandler(handler, { flushTimeout: 1337 });
198198
await wrappedHandler(fakeEvent, fakeContext, fakeCallback);
199-
expect(mockCaptureException).toBeCalledTimes(0);
199+
expect(mockCaptureException).toHaveBeenCalledTimes(0);
200200
});
201201

202202
test('captureAllSettledReasons enable', async () => {
@@ -212,7 +212,7 @@ describe('AWSLambda', () => {
212212
await wrappedHandler(fakeEvent, fakeContext, fakeCallback);
213213
expect(mockCaptureException).toHaveBeenNthCalledWith(1, error, expect.any(Function));
214214
expect(mockCaptureException).toHaveBeenNthCalledWith(2, error2, expect.any(Function));
215-
expect(mockCaptureException).toBeCalledTimes(2);
215+
expect(mockCaptureException).toHaveBeenCalledTimes(2);
216216
});
217217

218218
// "wrapHandler() ... successful execution" tests the default of startTrace enabled
@@ -223,10 +223,10 @@ describe('AWSLambda', () => {
223223
const wrappedHandler = wrapHandler(handler, { startTrace: false });
224224
await wrappedHandler(fakeEvent, fakeContext, fakeCallback);
225225

226-
expect(mockScope.addEventProcessor).toBeCalledTimes(0);
226+
expect(mockScope.addEventProcessor).toHaveBeenCalledTimes(0);
227227

228-
expect(mockScope.setTag).toBeCalledTimes(0);
229-
expect(mockStartSpanManual).toBeCalledTimes(0);
228+
expect(mockScope.setTag).toHaveBeenCalledTimes(0);
229+
expect(mockStartSpanManual).toHaveBeenCalledTimes(0);
230230
});
231231
});
232232

@@ -250,11 +250,11 @@ describe('AWSLambda', () => {
250250
};
251251

252252
expect(rv).toStrictEqual(42);
253-
expect(mockStartSpanManual).toBeCalledWith(fakeTransactionContext, expect.any(Function));
253+
expect(mockStartSpanManual).toHaveBeenCalledWith(fakeTransactionContext, expect.any(Function));
254254
expectScopeSettings();
255255

256-
expect(mockSpanEnd).toBeCalled();
257-
expect(mockFlush).toBeCalledWith(2000);
256+
expect(mockSpanEnd).toHaveBeenCalled();
257+
expect(mockFlush).toHaveBeenCalledWith(2000);
258258
});
259259

260260
test('unsuccessful execution', async () => {
@@ -278,12 +278,12 @@ describe('AWSLambda', () => {
278278
},
279279
};
280280

281-
expect(mockStartSpanManual).toBeCalledWith(fakeTransactionContext, expect.any(Function));
281+
expect(mockStartSpanManual).toHaveBeenCalledWith(fakeTransactionContext, expect.any(Function));
282282
expectScopeSettings();
283-
expect(mockCaptureException).toBeCalledWith(error, expect.any(Function));
283+
expect(mockCaptureException).toHaveBeenCalledWith(error, expect.any(Function));
284284

285-
expect(mockSpanEnd).toBeCalled();
286-
expect(mockFlush).toBeCalledWith(2000);
285+
expect(mockSpanEnd).toHaveBeenCalled();
286+
expect(mockFlush).toHaveBeenCalledWith(2000);
287287
}
288288
});
289289

@@ -320,12 +320,12 @@ describe('AWSLambda', () => {
320320
},
321321
};
322322

323-
expect(mockStartSpanManual).toBeCalledWith(fakeTransactionContext, expect.any(Function));
323+
expect(mockStartSpanManual).toHaveBeenCalledWith(fakeTransactionContext, expect.any(Function));
324324
expectScopeSettings();
325-
expect(mockCaptureException).toBeCalledWith(e, expect.any(Function));
325+
expect(mockCaptureException).toHaveBeenCalledWith(e, expect.any(Function));
326326

327-
expect(mockSpanEnd).toBeCalled();
328-
expect(mockFlush).toBeCalled();
327+
expect(mockSpanEnd).toHaveBeenCalled();
328+
expect(mockFlush).toHaveBeenCalled();
329329
}
330330
});
331331
});
@@ -350,11 +350,11 @@ describe('AWSLambda', () => {
350350
};
351351

352352
expect(rv).toStrictEqual(42);
353-
expect(mockStartSpanManual).toBeCalledWith(fakeTransactionContext, expect.any(Function));
353+
expect(mockStartSpanManual).toHaveBeenCalledWith(fakeTransactionContext, expect.any(Function));
354354
expectScopeSettings();
355355

356-
expect(mockSpanEnd).toBeCalled();
357-
expect(mockFlush).toBeCalled();
356+
expect(mockSpanEnd).toHaveBeenCalled();
357+
expect(mockFlush).toHaveBeenCalled();
358358
});
359359

360360
test('event and context are correctly passed to the original handler', async () => {
@@ -389,12 +389,12 @@ describe('AWSLambda', () => {
389389
},
390390
};
391391

392-
expect(mockStartSpanManual).toBeCalledWith(fakeTransactionContext, expect.any(Function));
392+
expect(mockStartSpanManual).toHaveBeenCalledWith(fakeTransactionContext, expect.any(Function));
393393
expectScopeSettings();
394-
expect(mockCaptureException).toBeCalledWith(error, expect.any(Function));
394+
expect(mockCaptureException).toHaveBeenCalledWith(error, expect.any(Function));
395395

396-
expect(mockSpanEnd).toBeCalled();
397-
expect(mockFlush).toBeCalled();
396+
expect(mockSpanEnd).toHaveBeenCalled();
397+
expect(mockFlush).toHaveBeenCalled();
398398
}
399399
});
400400

@@ -432,11 +432,11 @@ describe('AWSLambda', () => {
432432
};
433433

434434
expect(rv).toStrictEqual(42);
435-
expect(mockStartSpanManual).toBeCalledWith(fakeTransactionContext, expect.any(Function));
435+
expect(mockStartSpanManual).toHaveBeenCalledWith(fakeTransactionContext, expect.any(Function));
436436
expectScopeSettings();
437437

438-
expect(mockSpanEnd).toBeCalled();
439-
expect(mockFlush).toBeCalled();
438+
expect(mockSpanEnd).toHaveBeenCalled();
439+
expect(mockFlush).toHaveBeenCalled();
440440
});
441441

442442
test('event and context are correctly passed to the original handler', async () => {
@@ -471,12 +471,12 @@ describe('AWSLambda', () => {
471471
},
472472
};
473473

474-
expect(mockStartSpanManual).toBeCalledWith(fakeTransactionContext, expect.any(Function));
474+
expect(mockStartSpanManual).toHaveBeenCalledWith(fakeTransactionContext, expect.any(Function));
475475
expectScopeSettings();
476-
expect(mockCaptureException).toBeCalledWith(error, expect.any(Function));
476+
expect(mockCaptureException).toHaveBeenCalledWith(error, expect.any(Function));
477477

478-
expect(mockSpanEnd).toBeCalled();
479-
expect(mockFlush).toBeCalled();
478+
expect(mockSpanEnd).toHaveBeenCalled();
479+
expect(mockFlush).toHaveBeenCalled();
480480
}
481481
});
482482
});
@@ -493,7 +493,7 @@ describe('AWSLambda', () => {
493493
try {
494494
await wrappedHandler(fakeEvent, fakeContext, fakeCallback);
495495
} catch (e) {
496-
expect(mockCaptureException).toBeCalledWith(error, expect.any(Function));
496+
expect(mockCaptureException).toHaveBeenCalledWith(error, expect.any(Function));
497497

498498
const scopeFunction = mockCaptureException.mock.calls[0][1];
499499
const event: Event = { exception: { values: [{}] } };
@@ -513,7 +513,7 @@ describe('AWSLambda', () => {
513513
test('calls Sentry.init with correct sdk info metadata', () => {
514514
init({});
515515

516-
expect(mockInit).toBeCalledWith(
516+
expect(mockInit).toHaveBeenCalledWith(
517517
expect.objectContaining({
518518
_metadata: {
519519
sdk: {

packages/browser/test/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ describe('SentryBrowser initialization', () => {
389389
const sdkData = getClient()?.getOptions()._metadata?.sdk || {};
390390

391391
expect(sdkData.packages?.[0]?.name).toBe('cdn:@sentry/browser');
392-
expect(utils.getSDKSource).toBeCalledTimes(1);
392+
expect(utils.getSDKSource).toHaveBeenCalledTimes(1);
393393
spy.mockRestore();
394394
});
395395

packages/browser/test/sdk.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ describe('init', () => {
176176

177177
init(options);
178178

179-
expect(consoleErrorSpy).toBeCalledTimes(1);
179+
expect(consoleErrorSpy).toHaveBeenCalledTimes(1);
180180
expect(consoleErrorSpy).toHaveBeenCalledWith(
181181
'[Sentry] You cannot run Sentry this way in a browser extension, check: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
182182
);
@@ -191,7 +191,7 @@ describe('init', () => {
191191

192192
init(options);
193193

194-
expect(consoleErrorSpy).toBeCalledTimes(1);
194+
expect(consoleErrorSpy).toHaveBeenCalledTimes(1);
195195
expect(consoleErrorSpy).toHaveBeenCalledWith(
196196
'[Sentry] You cannot run Sentry this way in a browser extension, check: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
197197
);
@@ -215,7 +215,7 @@ describe('init', () => {
215215

216216
init(options);
217217

218-
expect(consoleErrorSpy).toBeCalledTimes(0);
218+
expect(consoleErrorSpy).toHaveBeenCalledTimes(0);
219219

220220
consoleErrorSpy.mockRestore();
221221
WINDOW.location = originalLocation;
@@ -227,7 +227,7 @@ describe('init', () => {
227227

228228
init(options);
229229

230-
expect(consoleErrorSpy).toBeCalledTimes(0);
230+
expect(consoleErrorSpy).toHaveBeenCalledTimes(0);
231231

232232
consoleErrorSpy.mockRestore();
233233
});

packages/cloudflare/test/integrations/fetch.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ describe('WinterCGFetch instrumentation', () => {
164164
};
165165
fetchInstrumentationHandlerCallback(startHandlerData);
166166

167-
expect(addBreadcrumbSpy).toBeCalledWith(
167+
expect(addBreadcrumbSpy).toHaveBeenCalledWith(
168168
{
169169
category: 'fetch',
170170
data: {

0 commit comments

Comments
 (0)