test-utils: remove unnecessary wrapInTestApp wrapping that broke mount point discovery

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-04-01 14:45:39 +02:00
parent 2bbac57ce4
commit ae6250ce3e
2 changed files with 9 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/test-utils': patch
---
Remove unnecessary wrapping of elements rendered by `wrapInTestApp` and `renderInTestApp`, which was breaking mount discovery.
@@ -120,11 +120,11 @@ export function wrapInTestApp(
},
});
let Wrapper: ComponentType;
let wrappedElement: React.ReactElement;
if (Component instanceof Function) {
Wrapper = Component;
wrappedElement = <Component />;
} 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 */}
<Route path="*" element={<Wrapper />} />
<Route path="*" element={wrappedElement} />
</AppRouter>
</AppProvider>
);