Skip to content

Commit 9d105cd

Browse files
committed
update all tests for new addInstrumentationHandler
1 parent 3ec7566 commit 9d105cd

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

packages/tracing/test/browser/browsertracing.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jest.mock('@sentry/utils', () => {
2424
const actual = jest.requireActual('@sentry/utils');
2525
return {
2626
...actual,
27-
addInstrumentationHandler: ({ callback, type }: any): void => {
27+
addInstrumentationHandler: (type, callback): void => {
2828
if (type === 'history') {
2929
// rather than actually add the navigation-change handler, grab a reference to it, so we can trigger it manually
3030
mockChangeHistory = callback;

packages/tracing/test/browser/request.test.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,20 @@ describe('instrumentOutgoingRequests', () => {
2626
it('instruments fetch and xhr requests', () => {
2727
instrumentOutgoingRequests();
2828

29-
expect(addInstrumentationHandler).toHaveBeenCalledWith({
30-
callback: expect.any(Function),
31-
type: 'fetch',
32-
});
33-
expect(addInstrumentationHandler).toHaveBeenCalledWith({
34-
callback: expect.any(Function),
35-
type: 'xhr',
36-
});
29+
expect(addInstrumentationHandler).toHaveBeenCalledWith('fetch', expect.any(Function));
30+
expect(addInstrumentationHandler).toHaveBeenCalledWith('xhr', expect.any(Function));
3731
});
3832

3933
it('does not instrument fetch requests if traceFetch is false', () => {
4034
instrumentOutgoingRequests({ traceFetch: false });
4135

42-
expect(addInstrumentationHandler).not.toHaveBeenCalledWith({ callback: expect.any(Function), type: 'fetch' });
36+
expect(addInstrumentationHandler).not.toHaveBeenCalledWith('fetch', expect.any(Function));
4337
});
4438

4539
it('does not instrument xhr requests if traceXHR is false', () => {
4640
instrumentOutgoingRequests({ traceXHR: false });
4741

48-
expect(addInstrumentationHandler).not.toHaveBeenCalledWith({ callback: expect.any(Function), type: 'xhr' });
42+
expect(addInstrumentationHandler).not.toHaveBeenCalledWith('xhr', expect.any(Function));
4943
});
5044
});
5145

packages/tracing/test/browser/router.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jest.mock('@sentry/utils', () => {
88
const actual = jest.requireActual('@sentry/utils');
99
return {
1010
...actual,
11-
addInstrumentationHandler: ({ callback, type }: any): void => {
11+
addInstrumentationHandler: (type, callback): void => {
1212
addInstrumentationHandlerType = type;
1313
mockChangeHistory = callback;
1414
},

packages/tracing/test/errors.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jest.mock('@sentry/utils', () => {
2020
mockUnhandledRejectionCallback = callback;
2121
}
2222
if (typeof mockAddInstrumentationHandler === 'function') {
23-
return mockAddInstrumentationHandler({ callback, type });
23+
return mockAddInstrumentationHandler(type, callback);
2424
}
2525
},
2626
};
@@ -45,11 +45,8 @@ describe('registerErrorHandlers()', () => {
4545
it('registers error instrumentation', () => {
4646
registerErrorInstrumentation();
4747
expect(mockAddInstrumentationHandler).toHaveBeenCalledTimes(2);
48-
expect(mockAddInstrumentationHandler).toHaveBeenNthCalledWith(1, { callback: expect.any(Function), type: 'error' });
49-
expect(mockAddInstrumentationHandler).toHaveBeenNthCalledWith(2, {
50-
callback: expect.any(Function),
51-
type: 'unhandledrejection',
52-
});
48+
expect(mockAddInstrumentationHandler).toHaveBeenNthCalledWith(1, 'error', expect.any(Function));
49+
expect(mockAddInstrumentationHandler).toHaveBeenNthCalledWith(2, 'unhandledrejection', expect.any(Function));
5350
});
5451

5552
it('does not set status if transaction is not on scope', () => {

0 commit comments

Comments
 (0)