Use renderInTestApp

Signed-off-by: Karan Shah <karan.shah@simplybusiness.co.uk>
This commit is contained in:
Karan Shah
2021-12-30 14:44:15 +00:00
parent b4f2f650dc
commit 06d04183d0
2 changed files with 5 additions and 39 deletions
@@ -15,19 +15,13 @@
*/
import React from 'react';
import { render } from '@testing-library/react';
import { ThemeProvider } from '@material-ui/core';
import { lightTheme } from '@backstage/theme';
import { AirbrakeWidget } from './AirbrakeWidget';
import exampleData from './example-data.json';
import { renderInTestApp } from '@backstage/test-utils';
describe('AirbrakeWidget', () => {
it('renders all errors sent from Airbrake', async () => {
const table = await render(
<ThemeProvider theme={lightTheme}>
<AirbrakeWidget />
</ThemeProvider>,
);
const table = await renderInTestApp(<AirbrakeWidget />);
expect(exampleData.groups.length).toBeGreaterThan(0);
for (const group of exampleData.groups) {
expect(
+3 -31
View File
@@ -14,10 +14,8 @@
* limitations under the License.
*/
import React from 'react';
import { AirbrakeWidget, airbrakePlugin } from './plugin';
import { renderWithEffects } from '@backstage/test-utils';
import { createApp } from '@backstage/app-defaults';
import { Route } from 'react-router';
import { airbrakePlugin, AirbrakeWidget } from './plugin';
import { renderInTestApp } from '@backstage/test-utils';
describe('Airbrake', () => {
it('should export plugin', () => {
@@ -25,33 +23,7 @@ describe('Airbrake', () => {
});
it('should render page', async () => {
process.env = {
NODE_ENV: 'test',
APP_CONFIG: [
{
data: {
app: { title: 'Test' },
backend: { baseUrl: 'http://localhost:7000' },
techdocs: {
storageUrl: 'http://localhost:7000/api/techdocs/static/docs',
},
},
context: 'test',
},
] as any,
};
const app = createApp();
const AppProvider = app.getProvider();
const AppRouter = app.getRouter();
const rendered = await renderWithEffects(
<AppProvider>
<AppRouter>
<Route path="/airbrake" element={<AirbrakeWidget />} />
</AppRouter>
</AppProvider>,
);
const rendered = await renderInTestApp(<AirbrakeWidget />);
expect(rendered.getByText('ChunkLoadError')).toBeInTheDocument();
});
});