core-app-api: FlatRoutes compat test fixes
Co-authored-by: Fredrik Adelöw <freben@gmail.com> Co-authored-by: blam <ben@blam.sh> Co-authored-by: Johan Haals <johan.haals@gmail.com> Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -14,17 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { render, RenderResult } from '@testing-library/react';
|
||||
import tlr, { render, RenderResult } from '@testing-library/react';
|
||||
import React, { ReactNode } from 'react';
|
||||
import { LocalStorageFeatureFlags } from '../apis';
|
||||
import { featureFlagsApiRef } from '@backstage/core-plugin-api';
|
||||
import { AppContext } from '../app';
|
||||
import { AppContextProvider } from '../app/AppContext';
|
||||
import { TestApiProvider } from '@backstage/test-utils';
|
||||
|
||||
describe.each(['beta', 'stable'])('FlatRoutes %s', rrVersion => {
|
||||
beforeAll(() => {
|
||||
jest.doMock('react', () => React);
|
||||
// This has some side effects, so need this to be stable to avoid re-require
|
||||
jest.doMock('@testing-library/react', () => tlr);
|
||||
jest.doMock('react-router', () =>
|
||||
rrVersion === 'beta'
|
||||
? jest.requireActual('react-router-beta')
|
||||
@@ -50,11 +51,12 @@ describe.each(['beta', 'stable'])('FlatRoutes %s', rrVersion => {
|
||||
return {
|
||||
...(require('./FlatRoutes') as typeof import('./FlatRoutes')),
|
||||
...(require('react-router-dom') as typeof import('react-router-dom')),
|
||||
...(require('@backstage/test-utils') as typeof import('@backstage/test-utils')),
|
||||
};
|
||||
}
|
||||
|
||||
function makeRouteRenderer(node: ReactNode) {
|
||||
const { MemoryRouter } = requireDeps();
|
||||
const { MemoryRouter, TestApiProvider } = requireDeps();
|
||||
let rendered: RenderResult | undefined = undefined;
|
||||
|
||||
const Wrapper = ({ children }: { children?: React.ReactNode }) => (
|
||||
|
||||
Reference in New Issue
Block a user