Skip to content

Commit

Permalink
feat: cypress setup for angular e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aadiene committed Jul 20, 2021
1 parent 77b15bd commit 7a3d5d7
Show file tree
Hide file tree
Showing 11 changed files with 32,865 additions and 31,024 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"make": "npm run package:angular-app && electron-forge make",
"publish": "electron-forge publish",
"lint": "eslint --ext .ts .",
"test:e2e": "npm run test:angular-e2e && npm run test:electron-e2",
"test:angular-e2e": "npm-run-all -p -r start:angular-app start:angular-e2e",
"start:angular-e2e": "wait-on http://localhost:4200 && cd workspaces/angular-app && npm run cypress:run",
"test:electron-e2e": "npm run package && cross-env X_NODE_ENV=e2e-test node workspaces/electron-e2e/jasmine.js",
"clean": "shx rm -rf .webpack out node_modules workspaces/shared-lib/.dist workspaces/angular-app/node_modules workspaces/angular-app/.dist",
"version": "npx conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
Expand Down
31 changes: 31 additions & 0 deletions workspaces/angular-app/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,37 @@
"styles": ["src/styles.scss"],
"scripts": []
}
},
"cypress-run": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "angular-app:serve"
},
"configurations": {
"production": {
"devServerTarget": "angular-app:serve:production"
}
}
},
"cypress-open": {
"builder": "@cypress/schematic:cypress",
"options": {
"watch": true,
"headless": false
}
},
"e2e": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "angular-app:serve",
"watch": true,
"headless": false
},
"configurations": {
"production": {
"devServerTarget": "angular-app:serve:production"
}
}
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions workspaces/angular-app/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"integrationFolder": "cypress/integration",
"supportFile": "cypress/support/index.ts",
"videosFolder": "cypress/videos",
"screenshotsFolder": "cypress/screenshots",
"pluginsFile": "cypress/plugins/index.ts",
"fixturesFolder": "cypress/fixtures",
"baseUrl": "http://localhost:4200",
"screenshotOnRunFailure": false,
"video": false
}
5 changes: 5 additions & 0 deletions workspaces/angular-app/cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
7 changes: 7 additions & 0 deletions workspaces/angular-app/cypress/integration/spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
describe('My First Test', () => {
it('Visits the initial project page', () => {
cy.visit('/');
cy.contains('Welcome');
cy.contains('electron-angular-quick-start app is running!');
});
});
5 changes: 5 additions & 0 deletions workspaces/angular-app/cypress/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Plugins enable you to tap into, modify, or extend the internal behavior of Cypress
// For more info, visit https://on.cypress.io/plugins-api
module.exports = (_on, _config) => {
// configure plugins here
};
43 changes: 43 additions & 0 deletions workspaces/angular-app/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// ***********************************************
// This example namespace declaration will help
// with Intellisense and code completion in your
// IDE or Text Editor.
// ***********************************************
// declare namespace Cypress {
// interface Chainable<Subject = any> {
// customCommand(param: any): typeof customCommand;
// }
// }
//
// function customCommand(param: any): void {
// console.warn(param);
// }
//
// NOTE: You can use it like so:
// Cypress.Commands.add('customCommand', customCommand);
//
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
17 changes: 17 additions & 0 deletions workspaces/angular-app/cypress/support/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// When a command from ./commands is ready to use, import with `import './commands'` syntax
// import './commands';
8 changes: 8 additions & 0 deletions workspaces/angular-app/cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"include": ["**/*.ts"],
"compilerOptions": {
"sourceMap": false,
"types": ["cypress"]
}
}
Loading

0 comments on commit 7a3d5d7

Please sign in to comment.