diff --git a/.changeset/polite-cameras-sin.md b/.changeset/polite-cameras-sin.md new file mode 100644 index 0000000000..b7989be2c6 --- /dev/null +++ b/.changeset/polite-cameras-sin.md @@ -0,0 +1,5 @@ +--- +'@backstage/test-utils': patch +--- + +Remove unnecessary wrapping of elements rendered by `wrapInTestApp` and `renderInTestApp`, which was breaking mount discovery. diff --git a/packages/test-utils/src/testUtils/appWrappers.tsx b/packages/test-utils/src/testUtils/appWrappers.tsx index 301366cbbd..add7b4479c 100644 --- a/packages/test-utils/src/testUtils/appWrappers.tsx +++ b/packages/test-utils/src/testUtils/appWrappers.tsx @@ -120,11 +120,11 @@ export function wrapInTestApp( }, }); - let Wrapper: ComponentType; + let wrappedElement: React.ReactElement; if (Component instanceof Function) { - Wrapper = Component; + wrappedElement = ; } else { - Wrapper = () => Component as React.ReactElement; + wrappedElement = Component as React.ReactElement; } const routeElements = Object.entries(options.mountedRoutes ?? {}).map( @@ -153,7 +153,7 @@ export function wrapInTestApp( {routeElements} {/* The path of * here is needed to be set as a catch all, so it will render the wrapper element * and work with nested routes if they exist too */} - } /> + );