e2e-test: add test for backwards compatibility with React 17
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -71,6 +71,20 @@ export async function run() {
|
||||
env: { ...process.env, CI: undefined },
|
||||
});
|
||||
|
||||
await switchToReact17(appDir);
|
||||
|
||||
print(`Running 'yarn install' to install React 17`);
|
||||
await runPlain(['yarn', 'install'], { cwd: appDir });
|
||||
|
||||
print(`Running 'yarn tsc' with React 17`);
|
||||
await runPlain(['yarn', 'tsc'], { cwd: appDir });
|
||||
|
||||
print(`Running 'yarn test:e2e' with React 17`);
|
||||
await runPlain(['yarn', 'test:e2e'], {
|
||||
cwd: appDir,
|
||||
env: { ...process.env, CI: undefined },
|
||||
});
|
||||
|
||||
if (
|
||||
Boolean(process.env.POSTGRES_USER) ||
|
||||
Boolean(process.env.MYSQL_CONNECTION)
|
||||
@@ -393,6 +407,35 @@ async function createPlugin(options: {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch the entire project to use React 17
|
||||
*/
|
||||
async function switchToReact17(appDir: string) {
|
||||
const rootPkg = await fs.readJson(resolvePath(appDir, 'package.json'));
|
||||
rootPkg.resolutions = {
|
||||
...(rootPkg.resolutions || {}),
|
||||
react: '^17.0.0',
|
||||
'react-dom': '^17.0.0',
|
||||
'@types/react': '^17.0.0',
|
||||
'@types/react-dom': '^17.0.0',
|
||||
};
|
||||
await fs.writeJson(resolvePath(appDir, 'package.json'), rootPkg, {
|
||||
spaces: 2,
|
||||
});
|
||||
|
||||
await fs.writeFile(
|
||||
resolvePath(appDir, 'packages/app/src/index.tsx'),
|
||||
`import '@backstage/cli/asset-types';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import App from './App';
|
||||
|
||||
ReactDOM.render(<App />, document.getElementById('root'));
|
||||
`,
|
||||
'utf8',
|
||||
);
|
||||
}
|
||||
|
||||
/** Drops PG databases */
|
||||
async function dropDB(database: string, client: string) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user