Skip to content

Commit

Permalink
test: update initHeadless params to be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
rtpascual committed Sep 20, 2023
1 parent 08734a9 commit 38a0e37
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 12 additions & 2 deletions packages/amplify-e2e-core/src/init/initProjectHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,16 @@ export function amplifyStatus(cwd: string, expectedStatus: string, testingWithLa
});
}

export function initHeadless(cwd: string, envName: string, appId: string): Promise<void> {
return spawn(getCLIPath(), ['init', '--yes', '--envName', envName, '--appId', appId], { cwd, stripColors: true }).runAsync();
export function initHeadless(cwd: string, envName?: string, appId?: string): Promise<void> {
const cliArgs = ['init', '--yes'];

if (envName) {
cliArgs.push('--envName', envName);
}

if (appId) {
cliArgs.push('--appId', appId);
}

return spawn(getCLIPath(), cliArgs, { cwd, stripColors: true }).runAsync();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
createNewProjectDir,
deleteProject,
deleteProjectDir,
getAppId,
getBackendAmplifyMeta,
getParameters,
getProjectMeta,
Expand Down Expand Up @@ -79,7 +78,6 @@ describe('amplify init', () => {
const envName = 'devtest';
const resourceName = 'twoInitDefaultTest';
await initJSProjectWithProfile(projectRoot, { disableAmplifyAppCreation: false, name: resourceName, envName });
const appId = getAppId(projectRoot);
await expect(initHeadless(projectRoot, envName, appId)).rejects.toThrowError('Process exited with non zero exit code 1');
await expect(initHeadless(projectRoot)).rejects.toThrowError('Process exited with non zero exit code 1');
});
});

0 comments on commit 38a0e37

Please sign in to comment.