diff --git a/plugins/catalog/src/components/EntityLinksCard/IconLink.test.tsx b/plugins/catalog/src/components/EntityLinksCard/IconLink.test.tsx index be784ae3e8..509a3f3741 100644 --- a/plugins/catalog/src/components/EntityLinksCard/IconLink.test.tsx +++ b/plugins/catalog/src/components/EntityLinksCard/IconLink.test.tsx @@ -14,23 +14,16 @@ * limitations under the License. */ -import { lightTheme } from '@backstage/theme'; -import { ThemeProvider } from '@material-ui/core'; +import { renderInTestApp } from '@backstage/test-utils'; import CloudIcon from '@material-ui/icons/Cloud'; -import { render, screen } from '@testing-library/react'; +import { screen } from '@testing-library/react'; import React from 'react'; import { IconLink } from './IconLink'; describe('IconLink', () => { - it('should render an icon link', () => { - render( - - - , + it('should render an icon link', async () => { + await renderInTestApp( + , ); expect(screen.getByText('I am Link')).toBeInTheDocument(); diff --git a/plugins/code-climate/src/components/CodeClimateTable/CodeClimateTable.test.tsx b/plugins/code-climate/src/components/CodeClimateTable/CodeClimateTable.test.tsx index 70d34d0298..e5703a993e 100644 --- a/plugins/code-climate/src/components/CodeClimateTable/CodeClimateTable.test.tsx +++ b/plugins/code-climate/src/components/CodeClimateTable/CodeClimateTable.test.tsx @@ -15,18 +15,14 @@ */ import React from 'react'; -import { render } from '@testing-library/react'; +import { renderInTestApp } from '@backstage/test-utils'; import { CodeClimateTable } from './CodeClimateTable'; import { mockData } from '../../api/mock/mock-api'; -import { ThemeProvider } from '@material-ui/core'; -import { lightTheme } from '@backstage/theme'; describe('CodeClimateTable', () => { it('should render values in a table', async () => { - const table = await render( - - - , + const table = await renderInTestApp( + , ); expect(await table.findByText('3 months')).toBeInTheDocument(); expect(await table.findByText('88%')).toBeInTheDocument(); diff --git a/plugins/graphiql/src/components/GraphiQLBrowser/GraphiQLBrowser.test.tsx b/plugins/graphiql/src/components/GraphiQLBrowser/GraphiQLBrowser.test.tsx index 7724a2ae23..3156662bf3 100644 --- a/plugins/graphiql/src/components/GraphiQLBrowser/GraphiQLBrowser.test.tsx +++ b/plugins/graphiql/src/components/GraphiQLBrowser/GraphiQLBrowser.test.tsx @@ -15,41 +15,33 @@ */ import React from 'react'; -import { render } from '@testing-library/react'; +import { renderInTestApp } from '@backstage/test-utils'; import { GraphiQLBrowser } from './GraphiQLBrowser'; -import { ThemeProvider } from '@material-ui/core'; -import { lightTheme } from '@backstage/theme'; -jest.mock('graphiql', () => () => ''); +jest.mock('graphiql', () => ({ GraphiQL: () => '' })); describe('GraphiQLBrowser', () => { - it('should render error text if there are no endpoints', () => { - const rendered = render( - - - , - ); + it('should render error text if there are no endpoints', async () => { + const rendered = await renderInTestApp(); rendered.getByText('No endpoints available'); }); - it('should render endpoint tabs', () => { - const rendered = render( - - - , + it('should render endpoint tabs', async () => { + const rendered = await renderInTestApp( + , ); rendered.getByText('Endpoint A'); rendered.getByText('Endpoint B'); diff --git a/plugins/graphiql/src/components/GraphiQLPage/GraphiQLPage.test.tsx b/plugins/graphiql/src/components/GraphiQLPage/GraphiQLPage.test.tsx index 90f8edd4ad..9923facc7b 100644 --- a/plugins/graphiql/src/components/GraphiQLPage/GraphiQLPage.test.tsx +++ b/plugins/graphiql/src/components/GraphiQLPage/GraphiQLPage.test.tsx @@ -16,13 +16,9 @@ import React from 'react'; import { GraphiQLPage } from './GraphiQLPage'; -import { ThemeProvider } from '@material-ui/core'; -import { lightTheme } from '@backstage/theme'; import { act } from '@testing-library/react'; -import { renderWithEffects, TestApiProvider } from '@backstage/test-utils'; +import { renderInTestApp, TestApiProvider } from '@backstage/test-utils'; import { GraphQLBrowseApi, graphQlBrowseApiRef } from '../../lib/api'; -import { configApiRef } from '@backstage/core-plugin-api'; -import { ConfigReader } from '@backstage/core-app-api'; jest.mock('../GraphiQLBrowser', () => ({ GraphiQLBrowser: () => '', @@ -38,17 +34,9 @@ describe('GraphiQLPage', () => { }, }; - const rendered = await renderWithEffects( - - - - - , + const rendered = await renderInTestApp( + + , , ); act(() => { @@ -66,16 +54,9 @@ describe('GraphiQLPage', () => { }, }; - const rendered = await renderWithEffects( - - - - + const rendered = await renderInTestApp( + + , ); @@ -90,16 +71,9 @@ describe('GraphiQLPage', () => { }, }; - const rendered = await renderWithEffects( - - - - + const rendered = await renderInTestApp( + + , ); diff --git a/plugins/lighthouse/src/components/AuditList/AuditListForEntity.test.tsx b/plugins/lighthouse/src/components/AuditList/AuditListForEntity.test.tsx index 3e34eed6e3..59892e1475 100644 --- a/plugins/lighthouse/src/components/AuditList/AuditListForEntity.test.tsx +++ b/plugins/lighthouse/src/components/AuditList/AuditListForEntity.test.tsx @@ -16,11 +16,8 @@ import { Entity } from '@backstage/catalog-model'; import { EntityProvider } from '@backstage/plugin-catalog-react'; -import { lightTheme } from '@backstage/theme'; -import { ThemeProvider } from '@material-ui/core'; -import { render } from '@testing-library/react'; +import { renderInTestApp, TestApiProvider } from '@backstage/test-utils'; import React from 'react'; -import { MemoryRouter } from 'react-router-dom'; import { lighthouseApiRef, LighthouseRestApi, @@ -30,36 +27,18 @@ import { useWebsiteForEntity } from '../../hooks/useWebsiteForEntity'; import * as data from '../../__fixtures__/website-list-response.json'; import { AuditListForEntity } from './AuditListForEntity'; -import { ApiProvider } from '@backstage/core-app-api'; -import { errorApiRef } from '@backstage/core-plugin-api'; -import { TestApiRegistry } from '@backstage/test-utils'; - jest.mock('../../hooks/useWebsiteForEntity', () => ({ useWebsiteForEntity: jest.fn(), })); +const useWebsiteForEntityMock = useWebsiteForEntity as jest.Mock; + const websiteListResponse = data as WebsiteListResponse; const entityWebsite = websiteListResponse.items[0]; describe('', () => { - let apis: TestApiRegistry; - - const mockErrorApi: jest.Mocked = { - post: jest.fn(), - error$: jest.fn(), - }; - - beforeEach(() => { - apis = TestApiRegistry.from( - [lighthouseApiRef, new LighthouseRestApi('http://lighthouse')], - [errorApiRef, mockErrorApi], - ); - - (useWebsiteForEntity as jest.Mock).mockReturnValue({ - value: entityWebsite, - loading: false, - error: null, - }); + afterEach(() => { + jest.resetAllMocks(); }); const entity: Entity = { @@ -78,66 +57,55 @@ describe('', () => { }, }; - const subject = () => - render( - - - - - - - - - , - ); + const subject = () => ( + + + + + + ); it('renders the audit list for the entity', async () => { - const { findByText } = subject(); + useWebsiteForEntityMock.mockReturnValue({ + value: entityWebsite, + loading: false, + error: null, + }); + const { findByText } = await renderInTestApp(subject()); expect(await findByText(entityWebsite.url)).toBeInTheDocument(); }); - describe('where the data is loading', () => { - beforeEach(() => { - (useWebsiteForEntity as jest.Mock).mockReturnValue({ - value: null, - loading: true, - error: null, - }); + it('renders a Progress element where the data is loading', async () => { + useWebsiteForEntityMock.mockReturnValue({ + value: null, + loading: true, + error: null, }); - it('renders a Progress element', async () => { - const { findByTestId } = subject(); - expect(await findByTestId('progress')).toBeInTheDocument(); - }); + const { findByTestId } = await renderInTestApp(subject()); + expect(await findByTestId('progress')).toBeInTheDocument(); }); - describe('where there is an error loading data', () => { - beforeEach(() => { - (useWebsiteForEntity as jest.Mock).mockReturnValue({ - value: null, - loading: false, - error: 'error', - }); - }); - - it('renders nothing', async () => { - const { queryByTestId } = subject(); - expect(queryByTestId('AuditListTable')).toBeNull(); + it('renders nothing where there is an error loading data', async () => { + useWebsiteForEntityMock.mockReturnValue({ + value: null, + loading: false, + error: 'error', }); + const { queryByTestId } = await renderInTestApp(subject()); + expect(queryByTestId('AuditListTable')).toBeNull(); }); - describe('where there is not data', () => { - beforeEach(() => { - (useWebsiteForEntity as jest.Mock).mockReturnValue({ - value: null, - loading: false, - error: null, - }); + it('renders nothing where there is not data', async () => { + useWebsiteForEntityMock.mockReturnValue({ + value: null, + loading: false, + error: null, }); - it('renders nothing', async () => { - const { queryByTestId } = subject(); - expect(queryByTestId('AuditListTable')).toBeNull(); - }); + const { queryByTestId } = await renderInTestApp(subject()); + expect(queryByTestId('AuditListTable')).toBeNull(); }); }); diff --git a/plugins/lighthouse/src/components/Cards/LastLighthouseAuditCard.test.tsx b/plugins/lighthouse/src/components/Cards/LastLighthouseAuditCard.test.tsx index ab1e2683b6..c59458f3f3 100644 --- a/plugins/lighthouse/src/components/Cards/LastLighthouseAuditCard.test.tsx +++ b/plugins/lighthouse/src/components/Cards/LastLighthouseAuditCard.test.tsx @@ -16,11 +16,8 @@ import { Entity } from '@backstage/catalog-model'; import { EntityProvider } from '@backstage/plugin-catalog-react'; -import { lightTheme } from '@backstage/theme'; -import { ThemeProvider } from '@material-ui/core'; -import { render } from '@testing-library/react'; +import { renderInTestApp } from '@backstage/test-utils'; import React from 'react'; -import { MemoryRouter } from 'react-router-dom'; import { AuditCompleted, LighthouseCategoryId, @@ -64,22 +61,15 @@ describe('', () => { }, }; - const subject = () => - render( - - - - - - - , - ); - describe('where the last audit completed successfully', () => { const audit = entityWebsite.lastAudit as AuditCompleted; it('renders the performance data for the audit', async () => { - const { findByText } = subject(); + const { findByText } = await renderInTestApp( + + + , + ); expect(await findByText(audit.url)).toBeInTheDocument(); expect(await findByText(audit.status)).toBeInTheDocument(); for (const category of Object.keys(audit.categories)) { @@ -101,7 +91,11 @@ describe('', () => { }); it('renders the performance data for the audit', async () => { - const { findByText } = subject(); + const { findByText } = await renderInTestApp( + + + , + ); expect(await findByText('N/A')).toBeInTheDocument(); }); }); @@ -119,7 +113,11 @@ describe('', () => { }); it('renders the url and status of the audit', async () => { - const { findByText } = subject(); + const { findByText } = await renderInTestApp( + + + , + ); expect(await findByText(audit.url)).toBeInTheDocument(); expect(await findByText(audit.status)).toBeInTheDocument(); }); @@ -135,7 +133,11 @@ describe('', () => { }); it('renders a Progress element', async () => { - const { findByTestId } = subject(); + const { findByTestId } = await renderInTestApp( + + + , + ); expect(await findByTestId('progress')).toBeInTheDocument(); }); }); @@ -150,7 +152,11 @@ describe('', () => { }); it('renders nothing', async () => { - const { queryByTestId } = subject(); + const { queryByTestId } = await renderInTestApp( + + + , + ); expect(queryByTestId('AuditListTable')).toBeNull(); }); }); @@ -165,7 +171,11 @@ describe('', () => { }); it('renders nothing', async () => { - const { queryByTestId } = subject(); + const { queryByTestId } = await renderInTestApp( + + + , + ); expect(queryByTestId('AuditListTable')).toBeNull(); }); }); diff --git a/plugins/scaffolder/src/components/TaskPage/IconLink.test.tsx b/plugins/scaffolder/src/components/TaskPage/IconLink.test.tsx index f7ce850cd8..0b6092c37d 100644 --- a/plugins/scaffolder/src/components/TaskPage/IconLink.test.tsx +++ b/plugins/scaffolder/src/components/TaskPage/IconLink.test.tsx @@ -14,23 +14,15 @@ * limitations under the License. */ -import { lightTheme } from '@backstage/theme'; -import { ThemeProvider } from '@material-ui/core'; +import { renderInTestApp } from '@backstage/test-utils'; import CloudIcon from '@material-ui/icons/Cloud'; -import { render } from '@testing-library/react'; import React from 'react'; import { IconLink } from './IconLink'; describe('IconLink', () => { - it('should render an icon link', () => { - const rendered = render( - - - , + it('should render an icon link', async () => { + const rendered = await renderInTestApp( + , ); expect(rendered.getByText('I am Link')).toBeInTheDocument(); diff --git a/plugins/sentry/src/components/ErrorCell/ErrorCell.test.tsx b/plugins/sentry/src/components/ErrorCell/ErrorCell.test.tsx index ff1960aa4f..22cb5cf0a0 100644 --- a/plugins/sentry/src/components/ErrorCell/ErrorCell.test.tsx +++ b/plugins/sentry/src/components/ErrorCell/ErrorCell.test.tsx @@ -16,10 +16,8 @@ import { ErrorCell } from './ErrorCell'; import React from 'react'; -import { render } from '@testing-library/react'; import mockIssue from '../../api/mock/sentry-issue-mock.json'; -import { ThemeProvider } from '@material-ui/core'; -import { lightTheme } from '@backstage/theme'; +import { renderInTestApp } from '@backstage/test-utils'; describe('Sentry error cell component', () => { it('should render a link that lead to Sentry', async () => { @@ -33,11 +31,7 @@ describe('Sentry error cell component', () => { userCount: 2, permalink: 'http://example.com', }; - const cell = render( - - - , - ); + const cell = await renderInTestApp(); const errorType = await cell.findByText('Exception'); expect(errorType.closest('a')).toHaveAttribute( 'href', @@ -53,11 +47,7 @@ describe('Sentry error cell component', () => { userCount: 2, permalink: 'http://example.com', }; - const cell = render( - - - , - ); + const cell = await renderInTestApp(); const errorType = await cell.findByText('Exception: Could not load cr...'); expect(errorType.closest('a')).toHaveAttribute( 'href', diff --git a/plugins/sentry/src/components/SentryIssuesTable/SentryIssuesTable.test.tsx b/plugins/sentry/src/components/SentryIssuesTable/SentryIssuesTable.test.tsx index 2516d37788..647208f141 100644 --- a/plugins/sentry/src/components/SentryIssuesTable/SentryIssuesTable.test.tsx +++ b/plugins/sentry/src/components/SentryIssuesTable/SentryIssuesTable.test.tsx @@ -15,12 +15,10 @@ */ import React from 'react'; -import { render } from '@testing-library/react'; import SentryIssuesTable from './SentryIssuesTable'; import { SentryIssue } from '../../api'; import mockIssue from '../../api/mock/sentry-issue-mock.json'; -import { ThemeProvider } from '@material-ui/core'; -import { lightTheme } from '@backstage/theme'; +import { renderInTestApp } from '@backstage/test-utils'; describe('SentryIssuesTable', () => { it('should render headers in a table', async () => { @@ -35,19 +33,17 @@ describe('SentryIssuesTable', () => { userCount: 2, }, ]; - const table = await render( - - - , + const table = await renderInTestApp( + , ); expect(await table.findByText('Error')).toBeInTheDocument(); expect(await table.findByText('Graph')).toBeInTheDocument(); @@ -68,19 +64,17 @@ describe('SentryIssuesTable', () => { userCount: 202, }, ]; - const table = await render( - - - , + const table = await renderInTestApp( + , ); expect(await table.findByText('Exception')).toBeInTheDocument(); expect(await table.findByText('exception was thrown')).toBeInTheDocument(); @@ -99,19 +93,17 @@ describe('SentryIssuesTable', () => { userCount: 202, }, ]; - const table = await render( - - - , + const table = await renderInTestApp( + , ); expect(await table.findByText('Last 24h')).toBeInTheDocument(); }); diff --git a/plugins/tech-radar/src/components/Radar/Radar.test.tsx b/plugins/tech-radar/src/components/Radar/Radar.test.tsx index 1b9e10ae5b..b76eb20a16 100644 --- a/plugins/tech-radar/src/components/Radar/Radar.test.tsx +++ b/plugins/tech-radar/src/components/Radar/Radar.test.tsx @@ -15,9 +15,7 @@ */ import React from 'react'; -import { render } from '@testing-library/react'; -import { ThemeProvider } from '@material-ui/core'; -import { lightTheme } from '@backstage/theme'; +import { renderInTestApp } from '@backstage/test-utils'; import GetBBoxPolyfill from '../../utils/polyfills/getBBox'; import Radar, { Props } from './Radar'; @@ -48,12 +46,8 @@ describe('Radar', () => { GetBBoxPolyfill.remove(); }); - it('should render', () => { - const rendered = render( - - - , - ); + it('should render', async () => { + const rendered = await renderInTestApp(); const svg = rendered.container.querySelector('svg'); expect(svg).not.toBeNull(); diff --git a/plugins/tech-radar/src/components/RadarBubble/RadarBubble.test.tsx b/plugins/tech-radar/src/components/RadarBubble/RadarBubble.test.tsx index 9af1f5caff..ab8070c146 100644 --- a/plugins/tech-radar/src/components/RadarBubble/RadarBubble.test.tsx +++ b/plugins/tech-radar/src/components/RadarBubble/RadarBubble.test.tsx @@ -15,9 +15,7 @@ */ import React from 'react'; -import { render } from '@testing-library/react'; -import { ThemeProvider } from '@material-ui/core'; -import { lightTheme } from '@backstage/theme'; +import { renderInTestApp } from '@backstage/test-utils'; import GetBBoxPolyfill from '../../utils/polyfills/getBBox'; import RadarBubble, { Props } from './RadarBubble'; @@ -38,13 +36,11 @@ describe('RadarBubble', () => { GetBBoxPolyfill.remove(); }); - it('should render', () => { - const rendered = render( - - - - - , + it('should render', async () => { + const rendered = await renderInTestApp( + + + , ); expect(rendered.getByText(minProps.text)).toBeInTheDocument(); diff --git a/plugins/tech-radar/src/components/RadarComponent.test.tsx b/plugins/tech-radar/src/components/RadarComponent.test.tsx index 3d3b1bfd17..4bb207a1de 100644 --- a/plugins/tech-radar/src/components/RadarComponent.test.tsx +++ b/plugins/tech-radar/src/components/RadarComponent.test.tsx @@ -15,10 +15,7 @@ */ import React from 'react'; -import { act, render, waitFor } from '@testing-library/react'; -import { ThemeProvider } from '@material-ui/core'; -import { lightTheme } from '@backstage/theme'; -import { TestApiProvider, withLogCollector } from '@backstage/test-utils'; +import { renderInTestApp, TestApiProvider } from '@backstage/test-utils'; import GetBBoxPolyfill from '../utils/polyfills/getBBox'; import { RadarComponent } from './RadarComponent'; @@ -36,7 +33,9 @@ describe('RadarComponent', () => { }); class MockClient implements TechRadarApi { + constructor(private delay = 0) {} async load(): Promise { + await new Promise(resolve => setTimeout(resolve, this.delay)); return { entries: [], quadrants: [], @@ -45,87 +44,52 @@ describe('RadarComponent', () => { } } - const mockClient = new MockClient(); - it('should render a progress bar', async () => { jest.useFakeTimers(); - const errorApi = { post: () => {} }; - const { getByTestId, findByTestId } = render( - - - - - , + const { findByTestId } = await renderInTestApp( + + + , ); - act(() => { - jest.advanceTimersByTime(250); - }); - expect(getByTestId('progress')).toBeInTheDocument(); + jest.advanceTimersByTime(250); + await expect(findByTestId('progress')).resolves.toBeInTheDocument(); + + jest.advanceTimersByTime(250); + await expect(findByTestId('tech-radar-svg')).resolves.toBeInTheDocument(); - await findByTestId('tech-radar-svg'); jest.useRealTimers(); }); it('should call the errorApi if load fails', async () => { const errorApi = { post: jest.fn() }; + const mockClient = new MockClient(); jest .spyOn(mockClient, 'load') .mockRejectedValue(new Error('404 Page Not Found')); - const { queryByTestId } = render( - - - - - , + const { queryByTestId } = await renderInTestApp( + + + , ); - await waitFor(() => !queryByTestId('progress')); - expect(errorApi.post).toHaveBeenCalledTimes(1); expect(errorApi.post).toHaveBeenCalledWith(new Error('404 Page Not Found')); expect(queryByTestId('tech-radar-svg')).not.toBeInTheDocument(); }); - - it('should not render without errorApiRef', () => { - expect( - withLogCollector(['error'], () => { - expect(() => { - render( - - - - - , - ); - }).toThrow(); - }).error[0], - ).toMatchObject({ - detail: new Error('No implementation available for apiRef{core.error}'), - }); - }); }); diff --git a/plugins/tech-radar/src/components/RadarDescription/RadarDescription.test.tsx b/plugins/tech-radar/src/components/RadarDescription/RadarDescription.test.tsx index 7249b9f194..7f2dcbe6ac 100644 --- a/plugins/tech-radar/src/components/RadarDescription/RadarDescription.test.tsx +++ b/plugins/tech-radar/src/components/RadarDescription/RadarDescription.test.tsx @@ -15,11 +15,10 @@ */ import React from 'react'; -import { render, screen } from '@testing-library/react'; -import { ThemeProvider } from '@material-ui/core'; -import { lightTheme } from '@backstage/theme'; +import { screen } from '@testing-library/react'; import { Props, RadarDescription } from './RadarDescription'; +import { renderInTestApp } from '@backstage/test-utils'; const minProps: Props = { open: true, @@ -29,12 +28,8 @@ const minProps: Props = { }; describe('RadarDescription', () => { - it('should render', () => { - render( - - - , - ); + it('should render', async () => { + await renderInTestApp(); const radarDescription = screen.getByTestId('radar-description'); expect(radarDescription).toBeInTheDocument(); diff --git a/plugins/tech-radar/src/components/RadarEntry/RadarEntry.test.tsx b/plugins/tech-radar/src/components/RadarEntry/RadarEntry.test.tsx index b1e468899d..36f304330d 100644 --- a/plugins/tech-radar/src/components/RadarEntry/RadarEntry.test.tsx +++ b/plugins/tech-radar/src/components/RadarEntry/RadarEntry.test.tsx @@ -15,10 +15,9 @@ */ import React from 'react'; -import { render, screen } from '@testing-library/react'; +import { screen } from '@testing-library/react'; +import { renderInTestApp } from '@backstage/test-utils'; import userEvent from '@testing-library/user-event'; -import { ThemeProvider } from '@material-ui/core'; -import { lightTheme } from '@backstage/theme'; import GetBBoxPolyfill from '../../utils/polyfills/getBBox'; import RadarEntry, { Props } from './RadarEntry'; @@ -45,13 +44,11 @@ describe('RadarEntry', () => { GetBBoxPolyfill.remove(); }); - it('should render link only', () => { - render( - - - - - , + it('should render link only', async () => { + await renderInTestApp( + + + , ); const radarEntry = screen.getByTestId('radar-entry'); @@ -62,12 +59,10 @@ describe('RadarEntry', () => { }); it('should render with description', async () => { - render( - - - - - , + await renderInTestApp( + + + , ); await userEvent.click(screen.getByRole('button')); @@ -80,17 +75,15 @@ describe('RadarEntry', () => { expect(screen.getByText(String(minProps.value))).toBeInTheDocument(); }); - it('should render blip with url equal to # if description present', () => { + it('should render blip with url equal to # if description present', async () => { const withUrl = { ...optionalProps, url: 'http://backstage.io', }; - render( - - - - - , + await renderInTestApp( + + + , ); expect(screen.getByRole('button')).toHaveAttribute('href', '#'); diff --git a/plugins/tech-radar/src/components/RadarFooter/RadarFooter.test.tsx b/plugins/tech-radar/src/components/RadarFooter/RadarFooter.test.tsx index b76405f2bf..df56e2ad2c 100644 --- a/plugins/tech-radar/src/components/RadarFooter/RadarFooter.test.tsx +++ b/plugins/tech-radar/src/components/RadarFooter/RadarFooter.test.tsx @@ -15,9 +15,7 @@ */ import React from 'react'; -import { render } from '@testing-library/react'; -import { ThemeProvider } from '@material-ui/core'; -import { lightTheme } from '@backstage/theme'; +import { renderInTestApp } from '@backstage/test-utils'; import GetBBoxPolyfill from '../../utils/polyfills/getBBox'; import RadarFooter, { Props } from './RadarFooter'; @@ -36,13 +34,11 @@ describe('RadarFooter', () => { GetBBoxPolyfill.remove(); }); - it('should render', () => { - const rendered = render( - - - - - , + it('should render', async () => { + const rendered = await renderInTestApp( + + + , ); const radarFooter = rendered.getByTestId('radar-footer'); const { x, y } = minProps; diff --git a/plugins/tech-radar/src/components/RadarGrid/RadarGrid.test.tsx b/plugins/tech-radar/src/components/RadarGrid/RadarGrid.test.tsx index d5636d74b8..2e0a5a225c 100644 --- a/plugins/tech-radar/src/components/RadarGrid/RadarGrid.test.tsx +++ b/plugins/tech-radar/src/components/RadarGrid/RadarGrid.test.tsx @@ -15,9 +15,7 @@ */ import React from 'react'; -import { render } from '@testing-library/react'; -import { ThemeProvider } from '@material-ui/core'; -import { lightTheme } from '@backstage/theme'; +import { renderInTestApp } from '@backstage/test-utils'; import GetBBoxPolyfill from '../../utils/polyfills/getBBox'; import RadarGrid, { Props } from './RadarGrid'; @@ -36,13 +34,11 @@ describe('RadarGrid', () => { GetBBoxPolyfill.remove(); }); - it('should render', () => { - const rendered = render( - - - - - , + it('should render', async () => { + const rendered = await renderInTestApp( + + + , ); expect(rendered.getByTestId('radar-grid-x-line')).toBeInTheDocument(); diff --git a/plugins/tech-radar/src/components/RadarLegend/RadarLegend.test.tsx b/plugins/tech-radar/src/components/RadarLegend/RadarLegend.test.tsx index e0b5f09a63..de8bfd15d7 100644 --- a/plugins/tech-radar/src/components/RadarLegend/RadarLegend.test.tsx +++ b/plugins/tech-radar/src/components/RadarLegend/RadarLegend.test.tsx @@ -14,9 +14,7 @@ * limitations under the License. */ -import { lightTheme } from '@backstage/theme'; -import { ThemeProvider } from '@material-ui/core'; -import { render } from '@testing-library/react'; +import { renderInTestApp } from '@backstage/test-utils'; import React from 'react'; import GetBBoxPolyfill from '../../utils/polyfills/getBBox'; @@ -47,13 +45,11 @@ describe('RadarLegend', () => { GetBBoxPolyfill.remove(); }); - it('should render', () => { - const rendered = render( - - - - - , + it('should render', async () => { + const rendered = await renderInTestApp( + + + , ); expect(rendered.getByTestId('radar-legend')).toBeInTheDocument(); diff --git a/plugins/tech-radar/src/components/RadarPlot/RadarPlot.test.tsx b/plugins/tech-radar/src/components/RadarPlot/RadarPlot.test.tsx index fd03111b49..7557755ed2 100644 --- a/plugins/tech-radar/src/components/RadarPlot/RadarPlot.test.tsx +++ b/plugins/tech-radar/src/components/RadarPlot/RadarPlot.test.tsx @@ -15,9 +15,7 @@ */ import React from 'react'; -import { render } from '@testing-library/react'; -import { ThemeProvider } from '@material-ui/core'; -import { lightTheme } from '@backstage/theme'; +import { renderInTestApp } from '@backstage/test-utils'; import GetBBoxPolyfill from '../../utils/polyfills/getBBox'; import RadarPlot, { Props } from './RadarPlot'; @@ -49,13 +47,11 @@ describe('RadarPlot', () => { GetBBoxPolyfill.remove(); }); - it('should render', () => { - const rendered = render( - - - - - , + it('should render', async () => { + const rendered = await renderInTestApp( + + + , ); expect(rendered.getByTestId('radar-plot')).toBeInTheDocument();