Skip to content

Commit ab1627d

Browse files
committed
fix tests
1 parent ddf5bcc commit ab1627d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

packages/vue/test/router.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import * as SentryBrowser from '@sentry/browser';
22
import * as SentryCore from '@sentry/core';
3-
import type { Span } from '@sentry/core';
43
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';
5-
import type { SpanAttributes } from '@sentry/types';
4+
import type { Span, SpanAttributes } from '@sentry/types';
65

76
import type { Route } from '../src/router';
87
import { instrumentVueRouter } from '../src/router';
@@ -129,12 +128,13 @@ describe('instrumentVueRouter()', () => {
129128
'should return instrumentation that instruments VueRouter.beforeEach(%s, %s) for pageloads',
130129
(fromKey, toKey, transactionName, transactionSource) => {
131130
const mockRootSpan = {
131+
getSpanJSON: jest.fn().mockReturnValue({ op: 'pageload' }),
132132
updateName: jest.fn(),
133133
setAttribute: jest.fn(),
134134
setAttributes: jest.fn(),
135135
};
136136

137-
jest.spyOn(SentryCore, 'getRootSpan').mockImplementation(() => mockRootSpan as unknown as Span);
137+
const spy = jest.spyOn(SentryCore, 'getRootSpan').mockImplementation(() => mockRootSpan as unknown as Span);
138138

139139
const mockStartSpan = jest.fn().mockImplementation(_ => {
140140
return mockRootSpan;
@@ -227,7 +227,8 @@ describe('instrumentVueRouter()', () => {
227227
setAttribute: jest.fn(),
228228
setAttributes: jest.fn(),
229229
name: '',
230-
toJSON: () => ({
230+
getSpanJSON: () => ({
231+
op: 'pageload',
231232
data: {
232233
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
233234
},
@@ -250,7 +251,8 @@ describe('instrumentVueRouter()', () => {
250251
// now we give the transaction a custom name, thereby simulating what would
251252
// happen when users use the `beforeNavigate` hook
252253
mockRootSpan.name = 'customTxnName';
253-
mockRootSpan.toJSON = () => ({
254+
mockRootSpan.getSpanJSON = () => ({
255+
op: 'pageload',
254256
data: {
255257
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',
256258
},
@@ -287,6 +289,7 @@ describe('instrumentVueRouter()', () => {
287289
setAttributes: jest.fn(),
288290
name: '',
289291
toJSON: () => ({
292+
op: 'pageload',
290293
data: {
291294
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
292295
},

0 commit comments

Comments
 (0)