I have implemented cypress in both ways(inside the development code repository and outside development repository as exclude code base).
Based on the strategy of deployment and testing, I choose to run CI/CD pipeline in both the code developments.
Scenario1: Team needed a BDD way of writing tests in cypress and they want to keep the tests outside development code since they maintain it for various projects under the belt of regression test pack for CI/CD consolidation.Refer an example:
Feature: MouseEvents verification in various compatibility models of devices
Scenario: Mouseactions on Dashboard Tab Graph using iPhone6 Mobile
Given I open OrangeHRM homepage
When I SignIn as user
When I see the page in iphone6 version
When I perform move actions on dashboard graph
Then text insights displayed below dashboard successfully
Example Code Base:
https://github.com/narayananpalani/cypress-test-techniques
Scenario2: Team wanted more of combined code base for a short term project in order to control the stubs and test them with UI verification.
Sample Code:
describe("Form test", () => {
it("Can fill the form", () => {
cy.visit("/");
cy.get("form");
cy.get('input[name="name"]')
.type("xxxx")
.should("have.value", "xxxx");
cy.get('input[name="email"]')
.type("[email protected]")
.should("have.value", "[email protected]");
cy.get("textarea")
.type("Mind you if I ask some silly question?")
.should("have.value", "Mind you if I ask some silly question?");
cy.server();
cy.route({
url: "/users/**",
method: "POST",
response: { status: "Form saved!", code: 201 }
});
cy.get("form").submit();
cy.contains("Form saved!");
});
});
Example Code Base:
https://github.com/narayananpalani/cypress-api-test-techniques
Now the critical part on where to learn them:
Cypress Cheat Sheets (Highly recommended):
https://narayananpalani.medium.com/cypress-cheat-sheet-for-testers-2c10febc864f
Alternative Link to download:
https://cheatography.com/narayanan-palani/cheat-sheets/cypressio/