Skip to content

Commit

Permalink
Revert "test: make test teardown resilient to failures (#12799)" (#12823
Browse files Browse the repository at this point in the history
)

This reverts commit ab04abf.
  • Loading branch information
jhockett committed Jun 16, 2023
1 parent aa43898 commit ec098ca
Showing 1 changed file with 12 additions and 24 deletions.
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);
});
});

0 comments on commit ec098ca

Please sign in to comment.