- "alexkrechik.cucumberautocomplete",
- "dylanmoerland.cypress-cucumber-steps"
- "streetsidesoftware.code-spell-checker"
Add below content in settings.json under .vscode folder
{
"cucumberautocomplete.steps": [
"./frontend/packages/*/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
- Design the gherkin scripts as per the Best Practices
- Design Gherkin scripts in same repo, where intellisense is provided by installed plugins to select the existing steps
- Execute
yarn run gherkin-lint
which scans the feature files as per the linter configuration file - Always comment the existing steps if it is related to older versions
- 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
- 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 )
- Avoid hard coded sleep statements like
cy.wait()
- Use arrow functions
- Implement the logics
- Don't use hard coded values like
waitTime
-
Page objects should be id, css selectors etc.. [No XPath]
- Each section should have one object as shown below (It helps to reduce the import list in scenarios)
export const devFilePO = {
form: '[data-test-id="import-devfile-form"]',
formFields: {
validatedMessage: '#form-input-git-url-field-helper',
advancedGitOptions: {
gitReference: '#form-input-git-ref-field',
contextDir: 'form-input-git-dir-field',
sourceSecret: '',
},
},
};
- 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
- Build the environment in your local as per the README.md present in console
- To execute the scripts, always update config file Cypress.json file as per the requirement
If you need to execute "regression" tagged scripts follow below process
- 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 browser present on top right corner of the dashboard [Note: it displays all installed browsers in your local machine]
Select the appropriate feature file and regression scripts get executed
Select the Run button present on top right corner
If you need to execute "smoke" tagged scripts present in single feature file then follow below process
- Update the TAGS under env section in config file Cypress.json file as "env": { "TAGS": "@smoke and not @manual" },
- 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]
- Reports are generated
- In command prompt, navigate to frontend folder and execute the command
yarn run cypress-merge
- Then execute command
yarn run cypress-generate
- cypress-report.html file is generated
- 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