- "alexkrechik.cucumberautocomplete",
- "dylanmoerland.cypress-cucumber-steps"
- "streetsidesoftware.code-spell-checker"
Add below content in settings.json under .vscode folder
{
"cucumberautocomplete.steps": [
"./frontend/packages/dev-console/integration-tests/support/step-definitions/*/*.ts",
"./frontend/packages/dev-console/integration-tests/support/step-definitions/*.ts"
],
"cucumberautocomplete.strictGherkinCompletion": true,
"editor.quickSuggestions": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
Folder structure of cypress cucumber framework
frontend/packages/dev-console/integration-tests/
├── features
| ├── addFlow <--- Add flow gherkin scenarios
| | └──create-from-git.feature
| ├── topology <--- Topology gherkin scenarios
| | └──chart-area-visual.feature
| ├── knative <--- Knative gherkin scenarios
| | └──create-event-sources.feature
| ├── helm <--- Helm gherkin scenarios
| | └──helm-navigation.feature
| ├── BestPractices.md <--- Gherkin script standards
├── plugins <--- Plugins provide a way to support and extend the behavior of cypress
| | └── index.ts
├── support <--- cypress cucumber support configurations
| ├── commands <--- add commands to Cypress 'cy.' global, other support configurations
| | └── index.ts
| | └── app.ts <--- hooks are added in this file
| ├── constants <--- enums required for dev-console scripts
| | | └──static-text
| | | └── add-fow-text.ts <--- enums required for dev-console scripts
│ | └── add.ts
| | └── global.ts
| ├── pageObjects <--- Object Repository [Going forward will publish it as npm module]
│ | ├── add-flow-po.ts <--- Add flow related page objects
| | └── helm-po.ts <--- Helm related page objects
| ├── pages <--- page functions
│ | ├── add-flow <--- Add flow related helper objects and page functions
| | | └──add-page.ts
| | └── app.ts <--- Re-usable helper objects and page functions
| ├── step-definitions <--- cucumber step implementations
│ | ├── addFlow <--- Re-usable dev-console step definitions
| | create-from-catalog.ts
| | └──project-creation.ts
│ | ├── common <--- Re-usable dev-console step definitions
| | └──common.ts
| | └──project-creation.ts
├── testData <--- Test data required for scripts
├── cypress.json <--- cypress configuration file
- Below practices helpful to design the gherkin scripts Best Practices for writing gherkin scripts
- Use the same repo for writing gherkin scripts, so that installed plugins gives you the intellisense to select the existing steps which helps to improve re-usability.
- To maintain gherkin standards, linter is used configuration file is available
- Execute the
yarn run gherkin-lint
command for every pr related to feature file, this helps in maintaining consistency - Always comment the steps if not useful [Don't delete them]
- Only validations should be present
- Don't use test data directly - It needs to be passed via data files (will use .ts files for now )
- Navigate to the "login.feature" file
- Select the command "Generate Steps from feature file" (By pressing "Ctrl+Shift+P" keys, commands will appear in vs code),
- "login" folder is generated with "login.ts" step definition file
- Add the comments wherever required
- Avoid hard coded sleep statements like
cy.wait()
- Page objects should be id, css selectors, buttontext etc.. [No XPath]- Already following
- Use arrow functions which helps to reduce the lines of code and it has other benefits as well
- Logics should be implemented within this files
- Don't use hard coded values like
waitTime
-
Page objects should be id, css selectors etc.. [No XPath]- Already following
- Each section should have one object as shown below (It helps to reduce the import list in scenarios)
export const deleteDeployPopupObj = {
form: element(by.css('form.modal-content')),
checkbox: element(by.css('input[type="checkbox"]')),
cancel: element(by.css('[data-test-id="modal-cancel-action"]')),
delete: element(by.css('#confirm-action'))
}
- Use arrow functions which helps to reduce the lines of code and it has other benefits as well
- Logics should be implemented within these files
- Don't use hard coded values [like waitTime]
- All test data should be maintained in frontend/testData
- file should end with "-data.ts"
- Comment the scenario file name, If data is relevant to specific scenario
- Epic related feature files needs to reviewed in 3 phases
- Review by QE team for standardization & Functional check [Peer Review]
- Review by Dev team [Preferably Feature owner]
- Assign to QE Lead for review
- To update the feature files not related to epics
- Review by QE team for standardization & Functional check [Peer Review]
- Assign to QE Lead for review
- Github adds a reviewer automatically for the PR
- Review by QE team for standardization [Peer Review]
- Review by Dev team [Optional]
- Assign to QE Lead for review
- If step definition is already available as part of other gherkin scripts, It should be moved to the appropriate file under step-definitions -> common folder
- No duplicates
- No console.log statements
- If functionality is not implemented, It should contain a comment like "// TODO: implement step"
- Avoid locators
- function names should be appropriate
- No Duplicate function names
- Add the appropriate comments, wherever applicable
- Number of lines in Function should be less than 10
- Number of lines in page should be less than 100
- Avoid page objects as much as possible [To reduce duplication]
- Code Readability
- file name should end with -page.ts
- Maintain Hierarchy
- Variable names should be meaningful
- file name should end with
-po.ts
- Drop down text, tiles etc.. related text maintained in appropriate file
- It should start with caps
- Under Static text folder
- error messages, warning or successful text are maintained
- use camel case for naming
- file name should end with
-text.ts
To execute the scripts, always update config file Cypress.json file as per the requirement
If you need to execute "regression" tagged scripts present in single feature file then follow below process
-
Build the environment in your local as per the README.md present in console
-
Update the TAGS under env section in config file Cypress.json file as "env": { "TAGS": "@regression and not @manual" },
-
In command prompt, navigate to frontend folder and execute the command "yarn test-cypress-devconsole"
-
Select the feature file and regression scripts get executed
-
All test data should be maintained in these files
-
Comment the scenario file name, If data is relevant to specific scenario
If you need to execute "regression" tagged scripts present in single feature file then follow below process
- If there is any functions which needs to be used in multiple files, include it in appFunctions file
- If functions are generic, include it in elementInteractions file
- Build the environment in your local as per the README.md present in console
- Update the TAGS under env section in config file Cypress.json file as "env": { "TAGS": "@regression and not @manual" },
- Navigate to package.json and update command "test-cypress-devconsole-headless" as per requirement
- In command prompt, navigate to frontend folder and execute the command "yarn test-cypress-devconsole-headless"
- All the regression scenarios get executed [Note: currently implementation is not done]
- Don't use static sleep statements (browser.sleep)
- Comments should be included wherever required
- Don't include console.log statements while raising PR
- .gherkin-lintrc configuration file present in frontend folder is used to set Gherkin standards
- Execute the "yarn run gherkin-lint" command for every QE pr Cypress Cucumber Handbook Cypress Cucumber Implementation