Skip to content

Commit

Permalink
test: fix uibuilder test (#10512)
Browse files Browse the repository at this point in the history
  • Loading branch information
lazpavel authored Jun 2, 2022
1 parent 681e4ee commit 6db6d66
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .eslint-dictionary.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"matcher",
"mfas",
"minify",
"mkdirs",
"mockable",
"modelfieldmapimpl",
"modelgen",
Expand All @@ -95,6 +96,7 @@
"pathname",
"pbkdf2Sync",
"pipelined",
"pkill",
"positionally",
"posix",
"postauthorcd",
Expand Down Expand Up @@ -136,6 +138,7 @@
"uibuilder",
"uint",
"unauth",
"unlink",
"updateamplify",
"urls",
"userpool",
Expand Down
20 changes: 14 additions & 6 deletions packages/amplify-e2e-tests/src/__tests__/uibuilder.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
getBackendAmplifyMeta, getAppId, amplifyPull, createNewProjectDir, deleteProject, deleteProjectDir, initJSProjectWithProfile,
} from 'amplify-e2e-core';
import {

getNpxPath, getNpmPath, myIconComponent, formCheckoutComponent,
} from 'amplify-e2e-core';
import { spawnSync, spawn } from 'child_process';
Expand All @@ -16,8 +15,17 @@ describe('amplify pull with uibuilder', () => {
let projectName: string;
let reactDir: string;
let appId: string;

const envName = 'integtest';
const cypressConfig = `
const { defineConfig } = require('cypress')
module.exports = defineConfig({
e2e: {
supportFile: false
}
})
`;
beforeEach(async () => {
projRoot = await createNewProjectDir('pull-uibuilder');
projRoot2 = await createNewProjectDir('pull-uibuilder-2');
Expand Down Expand Up @@ -54,7 +62,7 @@ describe('amplify pull with uibuilder', () => {
deleteProjectDir(reactDir);
});

it('appropriate uibiulder files are generated', async () => {
it('appropriate uibuilder files are generated', async () => {
spawnSync(getNpxPath(), ['create-react-app', projectName], { cwd: projectDir, encoding: 'utf-8' });
await amplifyPull(reactDir, { appId, envName, emptyDir: true });
const fileList = fs.readdirSync(`${reactDir}/src/ui-components/`);
Expand All @@ -74,10 +82,10 @@ describe('amplify pull with uibuilder', () => {

fs.unlinkSync(`${reactDir}/src/App.js`);
fs.writeFileSync(`${reactDir}/src/App.js`, fs.readFileSync(path.join(__dirname, '..', 'cypress', 'uibuilder', 'uibuilder-app.js')));
fs.writeFileSync(`${reactDir}/cypress.json`, '{}');
fs.mkdirsSync(`${reactDir}/cypress/integration/`);
fs.writeFileSync(`${reactDir}/cypress.config.js`, cypressConfig);
fs.mkdirsSync(`${reactDir}/cypress/e2e/`);
fs.writeFileSync(
`${reactDir}/cypress/integration/sample_spec.js`,
`${reactDir}/cypress/e2e/sample_spec.cy.js`,
fs.readFileSync(path.join(__dirname, '..', 'cypress', 'uibuilder', 'uibuilder-spec.js')),
);

Expand Down

0 comments on commit 6db6d66

Please sign in to comment.