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

e2e is migrated from practor to cypress #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ Type the following to run the demo.
```
ng serve
```
### Running the e2e
Type the following to run the e2e cypress test on open mode

```
ng e2e
```
### Live Demonstration

To see a live demonstration, go to [https://formio.github.io/angular-demo/](https://formio.github.io/angular-demo/)
65 changes: 59 additions & 6 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,44 @@
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
"src/tsconfig.spec.json",
"cypress/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"cypress-run": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "demo:serve"
},
"configurations": {
"production": {
"devServerTarget": "demo:serve:production"
}
}
},
"cypress-open": {
"builder": "@cypress/schematic:cypress",
"options": {
"watch": true,
"headless": false
}
},
"e2e": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "demo:serve",
"watch": true,
"headless": false
},
"configurations": {
"production": {
"devServerTarget": "demo:serve:production"
}
}
}
}
},
Expand All @@ -122,25 +154,46 @@
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"builder": "@cypress/schematic:cypress",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "demo:serve"
"devServerTarget": "demo-e2e:serve",
"watch": true,
"headless": false
},
"configurations": {
"production": {
"devServerTarget": "demo:serve:production"
"devServerTarget": "demo-e2e:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"tsConfig": "",
"exclude": [
"**/node_modules/**"
]
}
},
"cypress-run": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "demo-e2e:serve",
"configFile": "e2e//cypress.config.ts"
},
"configurations": {
"production": {
"devServerTarget": "demo-e2e:serve:production"
}
}
},
"cypress-open": {
"builder": "@cypress/schematic:cypress",
"options": {
"watch": true,
"headless": false,
"configFile": "e2e//cypress.config.ts"
}
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'cypress'

export default defineConfig({
e2e: {
'baseUrl': 'http://localhost:4200',
},
})
30 changes: 30 additions & 0 deletions cypress/e2e/spec.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
describe('My First Test', () => {
it('Visits the initial project page and verify components', () => {
cy.visit('/')
cy.get('.navbar-brand').should("be.visible")
cy.get('#navbarDropdown').should("be.visible")
cy.get('[href="https://form.io"] > img').should("be.visible")
cy.get('h2').should("be.visible")
cy.get('.jumbotron > p').should("be.visible")

})

it('verify form submission ', () => {

cy.get("input[name='data[firstName]']").should("be.visible").type("Some Name")
cy.get("[placeholder='Enter your last name']").type("Some Name")
cy.get("[name='data[email]']").type("[email protected]")
cy.get("[inputmode='decimal']").type("1234564545")
cy.get("[type='radio'][value='excellent']").eq(0).click()
cy.get("[type='radio'][value='excellent']").eq(1).click()
cy.get("[type='radio'][value='excellent']").eq(2).click()
cy.get('.signature-pad-canvas').click()
cy.get("button[name='data[submit]']").click()
cy.get(".alert.alert-success").should("be.visible")
cy.get("span[ref='buttonMessage']").should("be.visible")
cy.get(".btn-primary.submit-success").should("be.visible")
})



})
5 changes: 5 additions & 0 deletions 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]"
}

43 changes: 43 additions & 0 deletions 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 cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example support/component.ts 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 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"]
}
}
28 changes: 0 additions & 28 deletions e2e/protractor.conf.js

This file was deleted.

14 changes: 0 additions & 14 deletions e2e/src/app.e2e-spec.ts

This file was deleted.

11 changes: 0 additions & 11 deletions e2e/src/app.po.ts

This file was deleted.

13 changes: 0 additions & 13 deletions e2e/tsconfig.e2e.json

This file was deleted.

Loading