Cypress Best Practices - biswajitsundara/Cypress GitHub Wiki

  • Before automating anything, mention the view port height & width in cypress.json file
  • There are already validations in cypress commands for example when we use cy.visit() command it already checks the response code from the server so no need to include validations for each and every thing.
  • implicit & explicit validations, which is faster.
  • Page object model or BDD features are not usually recommended so customize your framework but don't loose the real strength of cypress
  • You can dump the API testing tool you currently use for your project and start using Cypress. When you have both UI & API automation in one framework that would be great.

Scenario #1

// This will not work! Cypress does not return the element synchronously.
const $cyElement = cy.get('.element');

Scenario #2

Lets say we have price amount with currency and we want to remove $

actualText= $el.text();
const res=actualText.split(" ");
const price = res[1].trim();
res[0] will have $

Scenario #3

Lets say we want to convert string to integer before adding up

const str1=10
const str2=20
Number(str1) + Number(str2);
⚠️ **GitHub.com Fallback** ⚠️