Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions packages/react/test/reactrouterv3.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,19 @@ describe('React Router V3', () => {
instrumentation(mockStartTransaction);
render(<Router history={history}>{routes}</Router>);

history.push('/about');
act(() => {
history.push('/about');
});
expect(mockStartTransaction).toHaveBeenCalledTimes(2);
expect(mockStartTransaction).toHaveBeenLastCalledWith({
name: '/about',
op: 'navigation',
tags: { from: '/', 'routing.instrumentation': 'react-router-v3' },
});

history.push('/features');
act(() => {
history.push('/features');
});
expect(mockStartTransaction).toHaveBeenCalledTimes(3);
expect(mockStartTransaction).toHaveBeenLastCalledWith({
name: '/features',
Expand All @@ -87,7 +91,9 @@ describe('React Router V3', () => {
instrumentation(mockStartTransaction);
render(<Router history={history}>{routes}</Router>);

history.replace('hello');
act(() => {
history.replace('hello');
});
expect(mockStartTransaction).toHaveBeenCalledTimes(1);
});

Expand All @@ -98,7 +104,9 @@ describe('React Router V3', () => {
render(<Router history={history}>{routes}</Router>);
expect(mockStartTransaction).toHaveBeenCalledTimes(1);

history.push('/features');
act(() => {
history.push('/features');
});
expect(mockFinish).toHaveBeenCalledTimes(1);
expect(mockStartTransaction).toHaveBeenCalledTimes(2);
});
Expand Down
24 changes: 18 additions & 6 deletions packages/react/test/reactrouterv4.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,19 @@ describe('React Router v4', () => {
</Router>,
);

history.push('/about');
act(() => {
history.push('/about');
});
expect(mockStartTransaction).toHaveBeenCalledTimes(2);
expect(mockStartTransaction).toHaveBeenLastCalledWith({
name: '/about',
op: 'navigation',
tags: { 'routing.instrumentation': 'react-router-v4' },
});

history.push('/features');
act(() => {
history.push('/features');
});
expect(mockStartTransaction).toHaveBeenCalledTimes(3);
expect(mockStartTransaction).toHaveBeenLastCalledWith({
name: '/features',
Expand Down Expand Up @@ -101,7 +105,9 @@ describe('React Router v4', () => {
</Router>,
);

history.replace('hello');
act(() => {
history.replace('hello');
});
expect(mockStartTransaction).toHaveBeenCalledTimes(1);
});

Expand All @@ -118,7 +124,9 @@ describe('React Router v4', () => {
);
expect(mockStartTransaction).toHaveBeenCalledTimes(1);

history.push('/features');
act(() => {
history.push('/features');
});
expect(mockFinish).toHaveBeenCalledTimes(1);
expect(mockStartTransaction).toHaveBeenCalledTimes(2);
});
Expand Down Expand Up @@ -237,15 +245,19 @@ describe('React Router v4', () => {
</Router>,
);

history.push('/organizations/1234/v1/758');
act(() => {
history.push('/organizations/1234/v1/758');
});
expect(mockStartTransaction).toHaveBeenCalledTimes(2);
expect(mockStartTransaction).toHaveBeenLastCalledWith({
name: '/organizations/:orgid/v1/:teamid',
op: 'navigation',
tags: { 'routing.instrumentation': 'react-router-v4' },
});

history.push('/organizations/1234');
act(() => {
history.push('/organizations/1234');
});
expect(mockStartTransaction).toHaveBeenCalledTimes(3);
expect(mockStartTransaction).toHaveBeenLastCalledWith({
name: '/organizations/:orgid',
Expand Down
26 changes: 19 additions & 7 deletions packages/react/test/reactrouterv5.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { act,render } from '@testing-library/react';
import { act, render } from '@testing-library/react';
import { createMemoryHistory } from 'history-4';
import * as React from 'react';
import { matchPath, Route, Router, Switch } from 'react-router-5';
Expand Down Expand Up @@ -58,15 +58,19 @@ describe('React Router v5', () => {
</Router>,
);

history.push('/about');
act(() => {
history.push('/about');
});
expect(mockStartTransaction).toHaveBeenCalledTimes(2);
expect(mockStartTransaction).toHaveBeenLastCalledWith({
name: '/about',
op: 'navigation',
tags: { 'routing.instrumentation': 'react-router-v5' },
});

history.push('/features');
act(() => {
history.push('/features');
});
expect(mockStartTransaction).toHaveBeenCalledTimes(3);
expect(mockStartTransaction).toHaveBeenLastCalledWith({
name: '/features',
Expand Down Expand Up @@ -101,7 +105,9 @@ describe('React Router v5', () => {
</Router>,
);

history.replace('hello');
act(() => {
history.replace('hello');
});
expect(mockStartTransaction).toHaveBeenCalledTimes(1);
});

Expand All @@ -118,7 +124,9 @@ describe('React Router v5', () => {
);
expect(mockStartTransaction).toHaveBeenCalledTimes(1);

history.push('/features');
act(() => {
history.push('/features');
});
expect(mockFinish).toHaveBeenCalledTimes(1);
expect(mockStartTransaction).toHaveBeenCalledTimes(2);
});
Expand Down Expand Up @@ -238,15 +246,19 @@ describe('React Router v5', () => {
</Router>,
);

history.push('/organizations/1234/v1/758');
act(() => {
history.push('/organizations/1234/v1/758');
});
expect(mockStartTransaction).toHaveBeenCalledTimes(2);
expect(mockStartTransaction).toHaveBeenLastCalledWith({
name: '/organizations/:orgid/v1/:teamid',
op: 'navigation',
tags: { 'routing.instrumentation': 'react-router-v5' },
});

history.push('/organizations/1234');
act(() => {
history.push('/organizations/1234');
});
expect(mockStartTransaction).toHaveBeenCalledTimes(3);
expect(mockStartTransaction).toHaveBeenLastCalledWith({
name: '/organizations/:orgid',
Expand Down