Skip to content

Commit

Permalink
test: turn off e2e test coverage, enable and fix import test (aws-amp…
Browse files Browse the repository at this point in the history
  • Loading branch information
jhockett authored and akshbhu committed Aug 15, 2021
1 parent b05bdbc commit f1ce3df
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/amplify-e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"/node_modules/",
"lib"
],
"collectCoverage": true,
"collectCoverage": false,
"collectCoverageFrom": [
"src/**/*.ts",
"!**/node_modules/**",
Expand Down
18 changes: 7 additions & 11 deletions packages/amplify-e2e-tests/src/__tests__/env.test.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import {
addAuthWithCustomTrigger,
addAuthWithDefault,
addAuthWithDefaultSocial,
addAuthWithRecaptchaTrigger,
amplifyPull,
amplifyPushAuth,
amplifyPushUpdate,
checkIfBucketExists,
createNewProjectDir,
deleteProject,
deleteProjectDir,
getProjectMeta,
initJSProjectWithProfile,
addAuthWithCustomTrigger,
amplifyPushAuth,
addAuthWithRecaptchaTrigger,
addAuthWithDefaultSocial,
} from 'amplify-e2e-core';
import {
addEnvironment,
addEnvironmentHostedUI,
checkoutEnvironment,
getEnvironment,
importEnvironment,
listEnvironment,
pullEnvironment,
removeEnvironment,
addEnvironmentHostedUI,
} from '../environment/env';

async function validate(meta: any) {
Expand Down Expand Up @@ -70,8 +70,7 @@ describe('environment commands', () => {
});
});

/* Disabling test for now */
describe.skip('cross project environment commands', () => {
describe('cross project environment commands', () => {
let projRoot: string;
beforeEach(async () => {
projRoot = await createNewProjectDir('import-env-test');
Expand All @@ -86,19 +85,16 @@ describe.skip('cross project environment commands', () => {
await initJSProjectWithProfile(projRoot, { envName: 'env' });
await addAuthWithDefault(projRoot, {});
const providerConfig: string = await getEnvironment(projRoot, { envName: 'env' });
expect(providerConfig === JSON.stringify(JSON.parse(providerConfig))).toBeTruthy();
await amplifyPushUpdate(projRoot);

let projRoot2: string;
try {
projRoot2 = await createNewProjectDir('import-env-test2');
await initJSProjectWithProfile(projRoot2, {});
await importEnvironment(projRoot2, { providerConfig, envName: 'env' });
await validate(getProjectMeta(projRoot));
await validate(getProjectMeta(projRoot2));
} catch (e) {
console.error(e);
} finally {
await deleteProject(projRoot2);
deleteProjectDir(projRoot2);
}
});
Expand Down
11 changes: 5 additions & 6 deletions packages/amplify-e2e-tests/src/environment/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ export function listEnvironment(cwd: string, settings: { numEnv?: number }): Pro
// Get environment details and return them as JSON
export function getEnvironment(cwd: string, settings: { envName: string }): Promise<string> {
const envData = {};
let helper = output => {
let keyVal = output.split(/:(.+)/); // Split string on first ':' only
envData[keyVal[0].trim()] = keyVal[1].trim();
const helper = (output: string) => {
const [key, value] = output.split(/:(.+)/); // Split string on first ':' only
envData[key.trim()] = value.trim();
};
return new Promise((resolve, reject) => {
spawn(getCLIPath(), ['env', 'get', '--name', settings.envName], { cwd, stripColors: true })
Expand All @@ -124,6 +124,7 @@ export function getEnvironment(cwd: string, settings: { envName: string }): Prom
.wait('Provider')
.wait('AuthRoleName', helper)
.wait('UnauthRoleArn', helper)
.wait(/^AuthRoleArn/, helper) // Needs to be a regex to prevent matching UnauthRoleArn twice
.wait('Region', helper)
.wait('DeploymentBucketName', helper)
.wait('UnauthRoleName', helper)
Expand All @@ -132,10 +133,8 @@ export function getEnvironment(cwd: string, settings: { envName: string }): Prom
.wait('--------------')
.sendEof()
.run((err: Error) => {
let jsonEnvData = JSON.stringify({ awscloudformation: envData });
if (!err) {
resolve(jsonEnvData);
return jsonEnvData;
resolve(JSON.stringify({ awscloudformation: envData }));
} else {
reject(err);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-migration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"/node_modules/",
"lib"
],
"collectCoverage": true,
"collectCoverage": false,
"collectCoverageFrom": [
"src/**/*.ts",
"!**/node_modules/**",
Expand Down

0 comments on commit f1ce3df

Please sign in to comment.