Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: UIBuilder test #14047

Merged
merged 5 commits into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions packages/amplify-e2e-tests/src/__tests__/uibuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ describe('amplify pull with uibuilder', () => {
let appId: string;

const envName = 'integtest';
// fixes recent esm module changes by removing require('cypress'), while still disabling supportFile
const cypressConfig = `
const { defineConfig } = require('cypress')

module.exports = defineConfig({
module.exports = {
e2e: {
supportFile: false
}
})
}
`;
beforeEach(async () => {
projRoot = await createNewProjectDir('pull-uibuilder');
Expand Down Expand Up @@ -98,7 +97,9 @@ describe('amplify pull with uibuilder', () => {
spawnSync(
getNpmPath(),
// in some runs spawnSync/npx will still use an old ver of react-scripts moving it into npm install flow
['install', '-E', '@types/react', 'cypress', '@aws-amplify/ui-react', 'aws-amplify', 'react-scripts@5'],
// using '--legacy-peer-deps' here as support for react 19 is not quite ready:
// see: https://github.com/aws-amplify/amplify-ui/issues/6084
['install', '-E', '@types/react', 'cypress', '@aws-amplify/ui-react', 'aws-amplify', 'react-scripts@5', '--legacy-peer-deps'],
{ cwd: reactDir },
);

Expand All @@ -110,11 +111,13 @@ describe('amplify pull with uibuilder', () => {
`${reactDir}/cypress/e2e/sample_spec.cy.js`,
fs.readFileSync(path.join(__dirname, '..', 'cypress', 'uibuilder', 'uibuilder-spec.js')),
);

const npmStartProcess = spawn(getNpmPath(), ['start'], { cwd: reactDir, timeout: 300000 });
// Give react server time to start
await new Promise((resolve) => setTimeout(resolve, 60000));
const res = execa.sync(getNpxPath(), ['cypress', 'run'], { cwd: reactDir, encoding: 'utf8' });
const res = execa.sync(getNpxPath(), ['cypress', 'run'], {
cwd: reactDir,
encoding: 'utf8',
});
// kill the react server process
spawnSync('kill', [`${npmStartProcess.pid}`], { encoding: 'utf8' });
await new Promise((resolve) => setTimeout(resolve, 1000));
Expand Down
Loading