2

I am new to Cypress and trying to find the best practices for where to store our tests. I see there seems to be plenty of resources for how to organize folders to setup fixtures, tests, plugins, etc. but I can't seem to find any recommendations if people actually store the tests with the front-end code that's being tested or in it's own separate repo?

Are there any advantages of one or the other when trying to setup CICD?

1

2 Answers 2

1

There are no best practices, only good practices in context. With the scripts configured correctly, nothing more than a make test is necessary.

E.g., If you have a Jenkins job to run your automated checks:

test:
    curl -X POST http://jenkins_server.com:port/job/job-name/build

If you have to fetch code from other sources, you can run a git clone or a wget.

In the end, after the abstractions are in place, the details barely matter.

0

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/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.