Skip to content

Commit

Permalink
fixed e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
roypeled committed Nov 21, 2023
1 parent 20421f3 commit 90c194c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"prebuild": "rimraf packages/*/build/",
"prerelease": "yarn build",
"release": "changeset publish",
"test": "yarn workspaces run test"
"test": "yarn workspaces run test",
"test:e2e": "./scripts/run-e2e-locally.sh"
},
"devDependencies": {
"@angular-devkit/build-angular": "^17.0.0",
Expand Down
7 changes: 4 additions & 3 deletions scripts/prepare-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ const [, , name, version] = process.argv;
function updateComponent() {
let filepath = path.join(cwd, `./${name}/src/app/app.component.ts`);
const code =
`import { Apollo } from 'apollo-angular';\n` +
`import { Apollo, ApolloModule } from 'apollo-angular';\n` +
`import { versionInfo } from 'graphql';\n` +
fs
.readFileSync(filepath, 'utf8')
.replace('AppComponent {', 'AppComponent { constructor(private apollo: Apollo) {}') +
.replace('AppComponent {', 'AppComponent { constructor(private apollo: Apollo) {}')
.replace('imports: [', 'imports: [ApolloModule, ')+
`\n (window as any).GRAPHQL_VERSION = versionInfo.major;`;

fs.writeFileSync(filepath, code, 'utf8');
Expand All @@ -24,7 +25,7 @@ function updateCypress() {
const code = fs
.readFileSync(filepath, 'utf8')
.replace(
`cy.contains('sandbox app is running!')`,
`cy.contains('app is running!')`,
`cy.window().its('GRAPHQL_VERSION').should('equal', ${version})`,
);

Expand Down
8 changes: 8 additions & 0 deletions scripts/run-e2e-locally.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rm -rf testapp
ng new testapp --package-manager yarn --defaults --minimal --skip-git
(cd testapp && ng add ../packages/apollo-angular/apollo-angular.tgz --graphql '16.0.0' --defaults --verbose --skip-confirmation)
(cd testapp && yarn ng run testapp:build:production)
(cd testapp && ng add @cypress/schematic --defaults --verbose --skip-confirmation)
./scripts/prepare-e2e.js testapp 16
(cd testapp && yarn ng run testapp:cypress-run:production)
rm -rf testapp

0 comments on commit 90c194c

Please sign in to comment.