1.1.9 • Published 3 years ago

@peterszeles/cypress-cucumber-testing v1.1.9

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Cypress Cucumber testing DSL 🥒 🚀

This is a project for UI/UX purposes with Cypress and Cucumber frameworks. There is implemented a unique DSL (Domain Specific Language) usage placed in folder cypress/tests/common.

Installation ⚙️

  • Install NodeJS \
  • Use the CLI to install this project.
git clone https://github.com/peterszeles/cypress-cucumber-testing.git
npm intall

Running ⏳

To open the Cypress UI use this command:

npx cypress open

To run a specific Gherkin test use this command:

cypress run --spec "**/filename.feature"

To run all Gherkin tests use this command:

npm test

Supported Gherkin commands 🥒 🔦

Given, When, Then, And

CommandExpression
Given / When / Then / AndI am on "string" page
Given / When / Then / AndI click on input "string"
Given / When / Then / AndI click on Nth "string"
Given / When / Then / AndI click on Nth "string" button
Given / When / Then / AndI click on "string"
Given / When / Then / AndI click on "string" button
Given / When / Then / AndI click on "string" link
Given / When / Then / AndI scroll "string" into view
Given / When / Then / AndI scroll to "string" at "string"
Given / When / Then / AndI see "string" in the title
Given / When / Then / AndI see "string" on the page
Given / When / Then / AndI select from dropdown "string" "string"
Given / When / Then / AndI select "string"
Given / When / Then / AndLabel "string" is present
Given / When / Then / AndSet email at label "string" to "string"
Given / When / Then / AndSet input at label "string" to "string"
Given / When / Then / AndSet input "string" to "string"
Given / When / Then / AndSet textarea at label "string" to "string"

Develop a Gherkin command 💻

Use any JavaScript file in test/common folder as a template

import {Given, When, Then, And} from "cypress-cucumber-preprocessor/steps";

Given(`Expression {string}`, (str) => {
    /** Here goes the implementation of the Gherkin command
     * Use the Cypress documentation for implementing the test.
     * @str is the variable from inside the Expression. 
     *      You can use STRING or NUMBER
     *      as many as it is **/ 
    
});

When(`Expression {string}`, (str) => {
    /** Here goes the implementation of the Gherkin command
     * Use the Cypress documentation for implementing the test.
     * @str is the variable from inside the Expression.
     *      You can use STRING or NUMBER
     *      as many as it is **/

});

Then(`Expression {string}`, (str) => {
    /** Here goes the implementation of the Gherkin command
     * Use the Cypress documentation for implementing the test.
     * @str is the variable from inside the Expression.
     *      You can use STRING or NUMBER
     *      as many as it is **/

});

And(`Expression {string}`, (str) => {
    /** Here goes the implementation of the Gherkin command
     * Use the Cypress documentation for implementing the test.
     * @str is the variable from inside the Expression.
     *      You can use STRING or NUMBER
     *      as many as it is **/

});

Usage ⚙️

Create a new folder at folder tests/common which describes the testing domain. Inside in this new folder create a Gherkin file type .feature

@custom-tag
  # The NAME of the feature testing file  
  Feature: The name of the feature

    # The description   
    Here goes the description

  # First scenario
    Given I am on "https://github.com/peterszeles/cypress-cucumber-testing" page
    When I click on "Go to file"
    Then I click on "cypress/fixtures/example.json"
    
  # Second scenario
  Scenario: Another scenario
    Given I am on "https://github.com/peterszeles/cypress-cucumber-testing/blob/master/cypress/fixtures/example.json" page
    Then I see "cypress-cucumber-testing" on the page

Google Sheets format 🗄

To use Google Sheets for implementig test scenarios

  • create a developer google site
  • cleate a google sheet
  • add your developer specific email
  • use the sheets/snippet.js file to run
node sheets/snippet.js

Contributing 🥒 📐✂️✒️

You are welcome to contribute on this project. By contributing you can make testers life easyer 🙂 \ Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License 🛒🔒

MIT

Links 🔗

KPI - Department of comupters and informatics \ Technical University of Kosice