Skip to content

Commit 5654640

Browse files
authored
fix: smoke test flakynes (#12760)
1 parent 9e81705 commit 5654640

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,17 @@ export type SmoketestArgs = {
3636
destructive: boolean;
3737
};
3838

39+
function defaultProjectDirectoryName(): string {
40+
let projectDir;
41+
do {
42+
projectDir = path.join(os.tmpdir(), `smoketest_${Math.floor(Math.random() * 1000000)}`);
43+
} while (fs.existsSync(projectDir));
44+
fs.ensureDirSync(projectDir);
45+
return projectDir;
46+
}
47+
3948
function getArgs(): SmoketestArgs {
40-
const { DESTRUCTIVE = 'false', CLI_VERSION = 'latest', PROJECT_DIRECTORY = path.join(os.tmpdir(), 'smoketest') } = process.env;
49+
const { DESTRUCTIVE = 'false', CLI_VERSION = 'latest', PROJECT_DIRECTORY = defaultProjectDirectoryName() } = process.env;
4150
return {
4251
projectDirectory: PROJECT_DIRECTORY,
4352
cliVersion: CLI_VERSION,
@@ -138,7 +147,7 @@ export class Amplify {
138147
.runAsync();
139148
};
140149
addRestApi = () => {
141-
return spawn(getCLIPath(), ['add', 'api'], { ...this.executionArgs, noOutputTimeout: 3000 })
150+
return spawn(getCLIPath(), ['add', 'api'], { ...this.executionArgs, noOutputTimeout: 10000 })
142151
.wait('Select from one of the below mentioned services')
143152
.sendKeyDown()
144153
.sendCarriageReturn()

0 commit comments

Comments
 (0)