Skip to content

Commit

Permalink
Merge pull request #4807 from backstage/rugvip/plugtempfix
Browse files Browse the repository at this point in the history
cli: fix plugin template by using renderInTestApp in component test
  • Loading branch information
benjdlambert committed Mar 4, 2021
2 parents f7f9a46 + 7117828 commit 5577fcb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 25 deletions.
@@ -1,11 +1,10 @@
import React from 'react';
import { render } from '@testing-library/react';
import { ExampleComponent } from './ExampleComponent';
import { ThemeProvider } from '@material-ui/core';
import { lightTheme } from '@backstage/theme';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
import { msw } from '@backstage/test-utils';
import { msw, renderInTestApp } from '@backstage/test-utils';

describe('ExampleComponent', () => {
const server = setupServer();
Expand All @@ -19,8 +18,8 @@ describe('ExampleComponent', () => {
);
});

it('should render', () => {
const rendered = render(
it('should render', async () => {
const rendered = await renderInTestApp(
<ThemeProvider theme={lightTheme}>
<ExampleComponent />
</ThemeProvider>,
Expand Down
53 changes: 32 additions & 21 deletions packages/e2e-test/src/commands/run.ts
Expand Up @@ -42,33 +42,44 @@ const templatePackagePaths = [
];

export async function run() {
const rootDir = await fs.mkdtemp(resolvePath(os.tmpdir(), 'backstage-e2e-'));
print(`CLI E2E test root: ${rootDir}\n`);

print('Building dist workspace');
const workspaceDir = await buildDistWorkspace('workspace', rootDir);

const isPostgres = Boolean(process.env.POSTGRES_USER);
print('Creating a Backstage App');
const appDir = await createApp('test-app', isPostgres, workspaceDir, rootDir);
try {
const rootDir = await fs.mkdtemp(
resolvePath(os.tmpdir(), 'backstage-e2e-'),
);
print(`CLI E2E test root: ${rootDir}\n`);

print('Building dist workspace');
const workspaceDir = await buildDistWorkspace('workspace', rootDir);

const isPostgres = Boolean(process.env.POSTGRES_USER);
print('Creating a Backstage App');
const appDir = await createApp(
'test-app',
isPostgres,
workspaceDir,
rootDir,
);

print('Creating a Backstage Plugin');
const pluginName = await createPlugin('test-plugin', appDir);
print('Creating a Backstage Plugin');
const pluginName = await createPlugin('test-plugin', appDir);

print('Creating a Backstage Backend Plugin');
await createPlugin('test-plugin', appDir, ['--backend']);
print('Creating a Backstage Backend Plugin');
await createPlugin('test-plugin', appDir, ['--backend']);

print('Starting the app');
await testAppServe(pluginName, appDir);
print('Starting the app');
await testAppServe(pluginName, appDir);

print('Testing the backend startup');
await testBackendStart(appDir, isPostgres);
print('Testing the backend startup');
await testBackendStart(appDir, isPostgres);

print('All tests successful, removing test dir');
await fs.remove(rootDir);
print('All tests successful, removing test dir');
await fs.remove(rootDir);

// Just in case some child process was left hanging
process.exit(0);
// Just in case some child process was left hanging
process.exit(0);
} catch {
process.exit(1);
}
}

/**
Expand Down

0 comments on commit 5577fcb

Please sign in to comment.