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

Revert "test: make test teardown resilient to failures" #12823

Merged
merged 1 commit into from
Jun 16, 2023
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
36 changes: 12 additions & 24 deletions packages/amplify-e2e-tests/src/__tests__/uibuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
enableAdminUI,
amplifyStudioHeadlessPull,
} from '@aws-amplify/amplify-e2e-core';
import { spawnSync, spawn, ChildProcessWithoutNullStreams } from 'child_process';
import { spawnSync, spawn } from 'child_process';
import { AmplifyUIBuilder } from 'aws-sdk';
import fs from 'fs-extra';
import path from 'path';
Expand Down Expand Up @@ -110,28 +110,16 @@ describe('amplify pull with uibuilder', () => {
fs.readFileSync(path.join(__dirname, '..', 'cypress', 'uibuilder', 'uibuilder-spec.js')),
);

let npmStartProcess: ChildProcessWithoutNullStreams;
let res: execa.ExecaSyncReturnValue<string>;
describe('cypress tests', () => {
beforeAll(async () => {
npmStartProcess = spawn(getNpmPath(), ['start'], { cwd: reactDir, timeout: 300000 });
// Give react server time to start
await new Promise((resolve) => setTimeout(resolve, 60000));
});

afterAll(async () => {
// kill the react server process
spawnSync('kill', [`${npmStartProcess.pid}`], { encoding: 'utf8' });
await new Promise((resolve) => setTimeout(resolve, 1000));
// Seriously, kill the react server process
// react-scripts somehow resurrects the process automatically after the first kill.
spawnSync('pkill', ['-f', 'react'], { encoding: 'utf8' });
});

it('...return exit code 0', () => {
res = execa.sync(getNpxPath(), ['cypress', 'run'], { cwd: reactDir, encoding: 'utf8' });
expect(res.exitCode).toBe(0);
});
});
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' });
// kill the react server process
spawnSync('kill', [`${npmStartProcess.pid}`], { encoding: 'utf8' });
await new Promise((resolve) => setTimeout(resolve, 1000));
// Seriously, kill the react server process
// react-scripts somehow resurrects the process automatically after the first kill.
spawnSync('pkill', ['-f', 'react'], { encoding: 'utf8' });
expect(res.exitCode).toBe(0);
});
});