test-utils: add missing Routes element wrapping

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-03-25 16:46:07 +01:00
parent 6a28dd4b8e
commit 7a5ddfd595
3 changed files with 17 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/test-utils': patch
---
Added missing `Routes` element to wrap the `Route` elements of the test app wrapping.
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/test-utils': patch
---
The internal elements created as part of the `mountedRoutes` implementation are now hidden during rendering.
@@ -15,7 +15,7 @@
*/
import React, { ComponentType, ReactNode, ReactElement } from 'react';
import { MemoryRouter } from 'react-router';
import { MemoryRouter, Routes } from 'react-router';
import { Route } from 'react-router-dom';
import { lightTheme } from '@backstage/theme';
import { ThemeProvider } from '@material-ui/core/styles';
@@ -70,6 +70,8 @@ const BootErrorPage = ({ step, error }: BootErrorPageProps) => {
};
const Progress = () => <div data-testid="progress" />;
const NoRender = (_props: { children: ReactNode }) => null;
/**
* Options to customize the behavior of the test app wrapper.
* @public
@@ -190,10 +192,12 @@ export function wrapInTestApp(
return (
<AppProvider>
<AppRouter>
{routeElements}
<NoRender>{routeElements}</NoRender>
{/* 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={wrappedElement} />
<Routes>
<Route path="/*" element={wrappedElement} />
</Routes>
</AppRouter>
</AppProvider>
);