feat: cypress setup for angular e2e tests
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
workspaces/angular-app/cypress.json
Normal file
11
workspaces/angular-app/cypress.json
Normal file
@@ -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
workspaces/angular-app/cypress/fixtures/example.json
Normal file
5
workspaces/angular-app/cypress/fixtures/example.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "Using fixtures to represent data",
|
||||
"email": "hello@cypress.io",
|
||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||
}
|
||||
7
workspaces/angular-app/cypress/integration/spec.ts
Normal file
7
workspaces/angular-app/cypress/integration/spec.ts
Normal file
@@ -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
workspaces/angular-app/cypress/plugins/index.ts
Normal file
5
workspaces/angular-app/cypress/plugins/index.ts
Normal file
@@ -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
workspaces/angular-app/cypress/support/commands.ts
Normal file
43
workspaces/angular-app/cypress/support/commands.ts
Normal file
@@ -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
workspaces/angular-app/cypress/support/index.ts
Normal file
17
workspaces/angular-app/cypress/support/index.ts
Normal file
@@ -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
workspaces/angular-app/cypress/tsconfig.json
Normal file
8
workspaces/angular-app/cypress/tsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"include": ["**/*.ts"],
|
||||
"compilerOptions": {
|
||||
"sourceMap": false,
|
||||
"types": ["cypress"]
|
||||
}
|
||||
}
|
||||
63750
workspaces/angular-app/package-lock.json
generated
63750
workspaces/angular-app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,10 @@
|
||||
"version": "2.0.0",
|
||||
"scripts": {
|
||||
"start": "ng serve",
|
||||
"package": "ng build --configuration production --base-href ./"
|
||||
"package": "ng build --configuration production --base-href ./",
|
||||
"e2e": "ng e2e",
|
||||
"cypress:open": "cypress open",
|
||||
"cypress:run": "cypress run"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
@@ -26,12 +29,14 @@
|
||||
"@angular-devkit/build-angular": "~12.1.2",
|
||||
"@angular/cli": "~12.1.2",
|
||||
"@angular/compiler-cli": "~12.1.2",
|
||||
"@cypress/schematic": "^1.4.2",
|
||||
"@types/node": "^12.11.1",
|
||||
"karma": "~6.3.0",
|
||||
"karma-chrome-launcher": "~3.1.0",
|
||||
"karma-coverage": "~2.0.3",
|
||||
"karma-jasmine": "~4.0.0",
|
||||
"karma-jasmine-html-reporter": "~1.7.0",
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.3.5",
|
||||
"cypress": "8.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user