Skip to content

Commit ec098ca

Browse files
authored
Revert "test: make test teardown resilient to failures (#12799)" (#12823)
This reverts commit ab04abf.
1 parent aa43898 commit ec098ca

File tree

1 file changed

+12
-24
lines changed

1 file changed

+12
-24
lines changed

packages/amplify-e2e-tests/src/__tests__/uibuilder.test.ts

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
enableAdminUI,
1414
amplifyStudioHeadlessPull,
1515
} from '@aws-amplify/amplify-e2e-core';
16-
import { spawnSync, spawn, ChildProcessWithoutNullStreams } from 'child_process';
16+
import { spawnSync, spawn } from 'child_process';
1717
import { AmplifyUIBuilder } from 'aws-sdk';
1818
import fs from 'fs-extra';
1919
import path from 'path';
@@ -110,28 +110,16 @@ describe('amplify pull with uibuilder', () => {
110110
fs.readFileSync(path.join(__dirname, '..', 'cypress', 'uibuilder', 'uibuilder-spec.js')),
111111
);
112112

113-
let npmStartProcess: ChildProcessWithoutNullStreams;
114-
let res: execa.ExecaSyncReturnValue<string>;
115-
describe('cypress tests', () => {
116-
beforeAll(async () => {
117-
npmStartProcess = spawn(getNpmPath(), ['start'], { cwd: reactDir, timeout: 300000 });
118-
// Give react server time to start
119-
await new Promise((resolve) => setTimeout(resolve, 60000));
120-
});
121-
122-
afterAll(async () => {
123-
// kill the react server process
124-
spawnSync('kill', [`${npmStartProcess.pid}`], { encoding: 'utf8' });
125-
await new Promise((resolve) => setTimeout(resolve, 1000));
126-
// Seriously, kill the react server process
127-
// react-scripts somehow resurrects the process automatically after the first kill.
128-
spawnSync('pkill', ['-f', 'react'], { encoding: 'utf8' });
129-
});
130-
131-
it('...return exit code 0', () => {
132-
res = execa.sync(getNpxPath(), ['cypress', 'run'], { cwd: reactDir, encoding: 'utf8' });
133-
expect(res.exitCode).toBe(0);
134-
});
135-
});
113+
const npmStartProcess = spawn(getNpmPath(), ['start'], { cwd: reactDir, timeout: 300000 });
114+
// Give react server time to start
115+
await new Promise((resolve) => setTimeout(resolve, 60000));
116+
const res = execa.sync(getNpxPath(), ['cypress', 'run'], { cwd: reactDir, encoding: 'utf8' });
117+
// kill the react server process
118+
spawnSync('kill', [`${npmStartProcess.pid}`], { encoding: 'utf8' });
119+
await new Promise((resolve) => setTimeout(resolve, 1000));
120+
// Seriously, kill the react server process
121+
// react-scripts somehow resurrects the process automatically after the first kill.
122+
spawnSync('pkill', ['-f', 'react'], { encoding: 'utf8' });
123+
expect(res.exitCode).toBe(0);
136124
});
137125
});

0 commit comments

Comments
 (0)