diff --git a/packages/react/test/reactrouterv3.test.tsx b/packages/react/test/reactrouterv3.test.tsx index e36a8d20d9ab..1faf7c7ce6f0 100644 --- a/packages/react/test/reactrouterv3.test.tsx +++ b/packages/react/test/reactrouterv3.test.tsx @@ -58,7 +58,9 @@ describe('React Router V3', () => { instrumentation(mockStartTransaction); render({routes}); - history.push('/about'); + act(() => { + history.push('/about'); + }); expect(mockStartTransaction).toHaveBeenCalledTimes(2); expect(mockStartTransaction).toHaveBeenLastCalledWith({ name: '/about', @@ -66,7 +68,9 @@ describe('React Router V3', () => { tags: { from: '/', 'routing.instrumentation': 'react-router-v3' }, }); - history.push('/features'); + act(() => { + history.push('/features'); + }); expect(mockStartTransaction).toHaveBeenCalledTimes(3); expect(mockStartTransaction).toHaveBeenLastCalledWith({ name: '/features', @@ -87,7 +91,9 @@ describe('React Router V3', () => { instrumentation(mockStartTransaction); render({routes}); - history.replace('hello'); + act(() => { + history.replace('hello'); + }); expect(mockStartTransaction).toHaveBeenCalledTimes(1); }); @@ -98,7 +104,9 @@ describe('React Router V3', () => { render({routes}); expect(mockStartTransaction).toHaveBeenCalledTimes(1); - history.push('/features'); + act(() => { + history.push('/features'); + }); expect(mockFinish).toHaveBeenCalledTimes(1); expect(mockStartTransaction).toHaveBeenCalledTimes(2); }); diff --git a/packages/react/test/reactrouterv4.test.tsx b/packages/react/test/reactrouterv4.test.tsx index 89caf7b398ee..60f617516482 100644 --- a/packages/react/test/reactrouterv4.test.tsx +++ b/packages/react/test/reactrouterv4.test.tsx @@ -58,7 +58,9 @@ describe('React Router v4', () => { , ); - history.push('/about'); + act(() => { + history.push('/about'); + }); expect(mockStartTransaction).toHaveBeenCalledTimes(2); expect(mockStartTransaction).toHaveBeenLastCalledWith({ name: '/about', @@ -66,7 +68,9 @@ describe('React Router v4', () => { tags: { 'routing.instrumentation': 'react-router-v4' }, }); - history.push('/features'); + act(() => { + history.push('/features'); + }); expect(mockStartTransaction).toHaveBeenCalledTimes(3); expect(mockStartTransaction).toHaveBeenLastCalledWith({ name: '/features', @@ -101,7 +105,9 @@ describe('React Router v4', () => { , ); - history.replace('hello'); + act(() => { + history.replace('hello'); + }); expect(mockStartTransaction).toHaveBeenCalledTimes(1); }); @@ -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); }); @@ -237,7 +245,9 @@ describe('React Router v4', () => { , ); - 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', @@ -245,7 +255,9 @@ describe('React Router v4', () => { 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', diff --git a/packages/react/test/reactrouterv5.test.tsx b/packages/react/test/reactrouterv5.test.tsx index 5d9cd66c9898..daa5a4fa5554 100644 --- a/packages/react/test/reactrouterv5.test.tsx +++ b/packages/react/test/reactrouterv5.test.tsx @@ -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'; @@ -58,7 +58,9 @@ describe('React Router v5', () => { , ); - history.push('/about'); + act(() => { + history.push('/about'); + }); expect(mockStartTransaction).toHaveBeenCalledTimes(2); expect(mockStartTransaction).toHaveBeenLastCalledWith({ name: '/about', @@ -66,7 +68,9 @@ describe('React Router v5', () => { tags: { 'routing.instrumentation': 'react-router-v5' }, }); - history.push('/features'); + act(() => { + history.push('/features'); + }); expect(mockStartTransaction).toHaveBeenCalledTimes(3); expect(mockStartTransaction).toHaveBeenLastCalledWith({ name: '/features', @@ -101,7 +105,9 @@ describe('React Router v5', () => { , ); - history.replace('hello'); + act(() => { + history.replace('hello'); + }); expect(mockStartTransaction).toHaveBeenCalledTimes(1); }); @@ -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); }); @@ -238,7 +246,9 @@ describe('React Router v5', () => { , ); - 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', @@ -246,7 +256,9 @@ describe('React Router v5', () => { 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',