From 48bd39b0731607116876ecc73d806a83b4f74006 Mon Sep 17 00:00:00 2001 From: peterszeles <peter.szeles@student.tuke.sk> Date: Sun, 18 Apr 2021 20:51:08 +0200 Subject: [PATCH] update README.md --- README.md | 122 +++++++++++++----- .../{bootstrap => examples}/bootstrap.feature | 4 +- cypress/tests/examples/github.feature | 13 ++ 3 files changed, 103 insertions(+), 36 deletions(-) rename cypress/tests/{bootstrap => examples}/bootstrap.feature (61%) create mode 100644 cypress/tests/examples/github.feature diff --git a/README.md b/README.md index 91e8a02..e858bf6 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# Cypress Cucumber testing DSL +# 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 +## Installation ⚙️ - Install [NodeJS](https://nodejs.org/en/) \ - Use the [CLI](https://www.w3schools.com/whatis/whatis_cli.asp) to install this project. @@ -14,7 +14,7 @@ git clone https://github.com/peterszeles/cypress-cucumber-testing.git npm intall ``` -## Running +## Running ⏳ To open the Cypress UI use this command: ```bash @@ -31,50 +31,98 @@ To run all Gherkin tests use this command: npm test ``` -## Supported Gherkin commands +## Supported Gherkin commands 🥒 🔦 Given, When, Then, And -| Command | Description | -| ------- | ----------- | -| I am on "string" page | | -| I click on input "string" | | -| I click on Nth "string" | | -| I click on Nth "string" button | | -| I click on "string" | | -| I click on "string" button | | -| I click on "string" link | | -| I scroll "string" into view | | -| I scroll to "string" at "string" | | -| I see "string" in the title | | -| I see "string" on the page | | -| I select from dropdown "string" "string" | | -| I select "string" | | -| Label "string" is present | | -| Set input at label "string" to "string" | | -| Set input "string" to "string" | | +| Command | Expression | +| --- | --- | +| Given / When / Then / And | I am on "string" page | +| Given / When / Then / And | I click on input "string" | +| Given / When / Then / And | I click on Nth "string" | +| Given / When / Then / And | I click on Nth "string" button | +| Given / When / Then / And | I click on "string" | +| Given / When / Then / And | I click on "string" button | +| Given / When / Then / And | I click on "string" link | +| Given / When / Then / And | I scroll "string" into view | +| Given / When / Then / And | I scroll to "string" at "string" | +| Given / When / Then / And | I see "string" in the title | +| Given / When / Then / And | I see "string" on the page | +| Given / When / Then / And | I select from dropdown "string" "string" | +| Given / When / Then / And | I select "string" | +| Given / When / Then / And | Label "string" is present | +| Given / When / Then / And | Set input at label "string" to "string" | +| Given / When / Then / And | Set input "string" to "string" | + + +## Develop a Gherkin command 💻 +Use any JavaScript file in test/common folder as a template +```javascript +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 **/ + +}); -```gherkin ``` -## Develop a Gherkin command - -## Usage - +## 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 ```gherkin @custom-tag + # The NAME of the feature testing file Feature: The name of the feature + # The description Here goes the description - Scenario: The name or description of scenario - Given I am on "https://getbootstrap.com/docs/5.0/forms/form-control/" page - When I set input at label "Email address" to "testUser@testemail.domain" - Then I set input at label "Example textaera" to "Lorem ipsum." + # 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 +## Google Sheets format 🗄 To use Google Sheets for implementig test scenarios - create a developer google site - cleate a google sheet @@ -84,10 +132,16 @@ To use Google Sheets for implementig test scenarios node sheets/snippet.js ``` -## Contributing +## 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 +## License 🛒🔒 [MIT](https://choosealicense.com/licenses/mit/) + +## Links 🔗 +[KPI - Department of comupters and informatics](https://kpi.fei.tuke.sk/en) \ +[Technical University of Kosice](https://www.tuke.sk/wps/portal) + diff --git a/cypress/tests/bootstrap/bootstrap.feature b/cypress/tests/examples/bootstrap.feature similarity index 61% rename from cypress/tests/bootstrap/bootstrap.feature rename to cypress/tests/examples/bootstrap.feature index 3d38f3f..6365a91 100644 --- a/cypress/tests/bootstrap/bootstrap.feature +++ b/cypress/tests/examples/bootstrap.feature @@ -5,5 +5,5 @@ Scenario: Testing the bootstrap components Given I am on "https://getbootstrap.com/docs/5.0/forms/form-control/" page - Then I set input at label "Email address" to "testUser@testemail.domain" - Then I set input at label "Example textaera" to "Lorem ipsum." + Then Set input at label "Email address" to "testUser@testemail.domain" + Then Set input at label "Example textaera" to "Lorem ipsum." diff --git a/cypress/tests/examples/github.feature b/cypress/tests/examples/github.feature new file mode 100644 index 0000000..2536a10 --- /dev/null +++ b/cypress/tests/examples/github.feature @@ -0,0 +1,13 @@ +@custom-tag +Feature: The name of the feature + + Here goes the description + + Scenario: The name or description of 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" + + 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