Skip to content

Commit 3aeee0e

Browse files
committed
Fix tests
1 parent 1b1c513 commit 3aeee0e

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

packages/react/test/reactrouter-cross-usage.test.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
} from 'react-router-6';
2727
import { beforeEach, describe, expect, it, vi } from 'vitest';
2828
import { BrowserClient } from '../src';
29+
import { allRoutes } from '../src/reactrouter-compat-utils/instrumentation';
2930
import {
3031
reactRouterV6BrowserTracingIntegration,
3132
withSentryReactRouterV6Routing,
@@ -101,6 +102,7 @@ describe('React Router cross usage of wrappers', () => {
101102
beforeEach(() => {
102103
vi.clearAllMocks();
103104
getCurrentScope().setClient(undefined);
105+
allRoutes.clear();
104106
});
105107

106108
describe('wrapCreateBrowserRouter and wrapUseRoutes', () => {
@@ -218,8 +220,7 @@ describe('React Router cross usage of wrappers', () => {
218220

219221
expect(container.innerHTML).toContain('Details');
220222

221-
// It's called 1 time from the wrapped `MemoryRouter`
222-
expect(mockStartBrowserTracingNavigationSpan).toHaveBeenCalledTimes(1);
223+
expect(mockStartBrowserTracingNavigationSpan).toHaveBeenCalledTimes(2);
223224
expect(mockStartBrowserTracingNavigationSpan).toHaveBeenLastCalledWith(expect.any(BrowserClient), {
224225
name: '/second-level/:id/third-level/:id',
225226
attributes: {
@@ -339,7 +340,6 @@ describe('React Router cross usage of wrappers', () => {
339340

340341
expect(container.innerHTML).toContain('Details');
341342

342-
// It's called 1 time from the wrapped `MemoryRouter`
343343
expect(mockStartBrowserTracingNavigationSpan).toHaveBeenCalledTimes(1);
344344
});
345345
});
@@ -465,8 +465,7 @@ describe('React Router cross usage of wrappers', () => {
465465

466466
expect(container.innerHTML).toContain('Details');
467467

468-
// It's called 1 time from the wrapped `createMemoryRouter`
469-
expect(mockStartBrowserTracingNavigationSpan).toHaveBeenCalledTimes(1);
468+
expect(mockStartBrowserTracingNavigationSpan).toHaveBeenCalledTimes(2);
470469

471470
expect(mockStartBrowserTracingNavigationSpan).toHaveBeenLastCalledWith(expect.any(BrowserClient), {
472471
name: '/second-level/:id/third-level/:id',
@@ -596,7 +595,7 @@ describe('React Router cross usage of wrappers', () => {
596595
);
597596

598597
expect(container.innerHTML).toContain('Details');
599-
expect(mockStartBrowserTracingNavigationSpan).toHaveBeenCalledTimes(1);
598+
expect(mockStartBrowserTracingNavigationSpan).toHaveBeenCalledTimes(2);
600599
expect(mockStartBrowserTracingNavigationSpan).toHaveBeenLastCalledWith(expect.any(BrowserClient), {
601600
name: '/second-level/:id/third-level/:id',
602601
attributes: {

packages/react/test/reactrouter-descendant-routes.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
} from 'react-router-6';
2626
import { beforeEach, describe, expect, it, vi } from 'vitest';
2727
import { BrowserClient } from '../src';
28+
import { allRoutes } from '../src/reactrouter-compat-utils/instrumentation';
2829
import {
2930
reactRouterV6BrowserTracingIntegration,
3031
withSentryReactRouterV6Routing,
@@ -79,6 +80,7 @@ describe('React Router Descendant Routes', () => {
7980
beforeEach(() => {
8081
vi.clearAllMocks();
8182
getCurrentScope().setClient(undefined);
83+
allRoutes.clear();
8284
});
8385

8486
describe('withSentryReactRouterV6Routing', () => {

packages/react/test/reactrouterv6.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
} from 'react-router-6';
2929
import { beforeEach, describe, expect, it, vi } from 'vitest';
3030
import { BrowserClient } from '../src';
31+
import { allRoutes } from '../src/reactrouter-compat-utils/instrumentation';
3132
import {
3233
reactRouterV6BrowserTracingIntegration,
3334
withSentryReactRouterV6Routing,
@@ -83,6 +84,7 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
8384
beforeEach(() => {
8485
vi.clearAllMocks();
8586
getCurrentScope().setClient(undefined);
87+
allRoutes.clear();
8688
});
8789

8890
it('wrapCreateMemoryRouterV6 starts and updates a pageload transaction - single initialEntry', () => {

0 commit comments

Comments
 (0)