https://github.com/ghoshasish99/cypress-cucumber
Web Testing with Cypress and Cucumber
https://github.com/ghoshasish99/cypress-cucumber
cucumber-js cypress cypress-cucumber webtesting
Last synced: 3 months ago
JSON representation
Web Testing with Cypress and Cucumber
- Host: GitHub
- URL: https://github.com/ghoshasish99/cypress-cucumber
- Owner: ghoshasish99
- Created: 2021-01-17T11:52:13.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-02-25T23:36:50.000Z (over 4 years ago)
- Last Synced: 2025-04-12T18:08:16.583Z (3 months ago)
- Topics: cucumber-js, cypress, cypress-cucumber, webtesting
- Language: JavaScript
- Homepage:
- Size: 86.9 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cypress with Cucumber
[](https://dev.azure.com/ContinuousTesting/Demo%20Project/_build/latest?definitionId=4&branchName=main)
This project describes how to implement Cypress with Cucumber
## Getting Started
* To install Cypress : `npm install cypress --save-dev`
* To install Cypress-Cucumber : `npm install cypress-cucumber-preprocessor --save-dev`
* To install Mocha Junit Reporter : `npm install mocha-junit-reporter --save-dev`
* To install Cypress Multi Reporters : `npm install cypress-multi-reporters --save-dev`
## To execute the testsDefine the scripts in `package.json` as follows :
```json
"scripts": {
"test": "npx cypress run"
}
```
Finally execute the tests with `npm test`### We will see how to use [Cypress Custom Commands](https://docs.cypress.io/api/cypress-api/custom-commands.html#Syntax)
Cypress recommends to use Custom Commands instead of Page Object Model.Inside `cypress/support/command.js` , add your reusable commands, like so :
```Javascript
Cypress.Commands.add("login", (username, password) => {
cy.get('#email').type(username)
cy.get('#password').type(password)
cy.get('form.login > .MuiButtonBase-root > .MuiButton-label').click()
})
```
### Use the custom commands in your step definitions, like so :
```Javascript
When('User logged in eshop using the invalid emailid {string} and the invalid password {string}', (username,password)=>{
cy.login(username,password)
})
```
### A sample Feature file
```gherkin
Scenario Outline: Login to the E-Shop Application with Wrong Password
Given User launched eshop login page
When User logged in eshop using the invalid emailid "" and the invalid password ""
Then User should not get logged inExamples:
| EmailID | Password |
| [email protected] | Testing$1 |
```
### cypress.json
You can specify the test files and reporting options inside cypress.json, like so :
```json
"testFiles" : [
"**/*.feature"
],
"reporter": "mocha-junit-reporter",
"reporterOptions": {
"mochaFile": "cypress/reports/junit/test-results.[hash].xml",
"testsuitesTitle": false
}
```
For more on Cypress, click [here](https://www.cypress.io/)