Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: turn off e2e test coverage, enable and fix import test #7776

Merged
merged 1 commit into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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