app,cli/templates: better mocking of app config in test

This commit is contained in:
Patrik Oldsberg
2020-06-21 15:17:24 +02:00
parent 6d9aaef9e7
commit d97842a69f
4 changed files with 27 additions and 17 deletions
+1
View File
@@ -15,6 +15,7 @@
"@backstage/plugin-sentry": "^0.1.1-alpha.9",
"@backstage/plugin-tech-radar": "^0.1.1-alpha.9",
"@backstage/plugin-welcome": "^0.1.1-alpha.9",
"@backstage/test-utils": "^0.1.1-alpha.9",
"@backstage/theme": "^0.1.1-alpha.9",
"@material-ui/core": "^4.9.1",
"@material-ui/icons": "^4.9.1",
+14 -13
View File
@@ -15,23 +15,24 @@
*/
import React from 'react';
import { render } from '@testing-library/react';
import { renderWithEffects } from '@backstage/test-utils';
import App from './App';
describe('App', () => {
beforeAll(() => {
Object.defineProperty(window, 'matchMedia', {
value: jest.fn(() => {
return {
matches: true,
addListener: jest.fn(),
removeListener: jest.fn(),
};
}),
it('should render', async () => {
Object.defineProperty(process.env, 'APP_CONFIG', {
configurable: true,
value: [
{
data: {
app: { title: 'Test' },
},
context: 'test',
},
],
});
});
it('should render', () => {
const rendered = render(<App />);
const rendered = await renderWithEffects(<App />);
expect(rendered.baseElement).toBeInTheDocument();
});
});