diff --git a/packages/rum-react/test/specs/get-apm-routes.spec.js b/packages/rum-react/test/specs/get-apm-routes.spec.js index 604d2f72e..9762ac010 100644 --- a/packages/rum-react/test/specs/get-apm-routes.spec.js +++ b/packages/rum-react/test/specs/get-apm-routes.spec.js @@ -252,6 +252,21 @@ describe('ApmRoutes', function () { ) } + function ComponentWithChild() { + navigate = useNavigate() + const [searchParams] = useSearchParams() + + if (searchParams.toString() === 'test=elastic') { + return
hello Elastic
+ } + + return ( +
+ +
+ ) + } + function Child(props) { return

Query params: {props.params}

} @@ -280,8 +295,8 @@ describe('ApmRoutes', function () { } ) - var childComponent = rendered.find(Child) - expect(childComponent.text()).toBe('Query params: ') + var component = rendered.find(ComponentWithChild) + expect(component.text()).toBe('Query params: ') transactionService.startTransaction.calls.reset() @@ -289,8 +304,7 @@ describe('ApmRoutes', function () { navigate('?test=elastic') expect(transactionService.startTransaction).not.toHaveBeenCalled() - - // Confirm the child component content is different than before - expect(childComponent.text()).toBe('Query params: test=elastic') + // Confirm the component content is different than before + expect(component.text()).toBe('hello Elastic') }) })