Categories
Technology

Tips & Tricks for Cypress

Photo by Hunter Haley on Unsplash

🏅 This post was featured in Software Testing Weekly, issue 55 🏅

This is a collection of simple and recurring scenarios when writing Cypress tests. For more complex recipes, check the official doc.

  • Setup
    • Abort cypress after first failed test
    • Read a test file from fixtures
  • Assertions
    • Assert the text of a page (string or number)
    • Assert the number of elements selected
    • Assert the result of two Cypress commands
  • Actions
    • Upload a file
  • Selectors
    • Given a list, return row that contains specific text
    • Selector is flaky due to page redesigns
    • Type text into input field and press enter
    • Select element inside iframe
    • Use selector X to narrow down area, and then use selector Y to find element
  • Waits
    • Wait until a network (ie. HTTP/XHR) request resolves
    • Wait until a condition becomes true
  • Mocks
    • Force a specific response to an HTTP request
Categories
Technology

Cypress: PageObjects using inheritance

Scenario:

  • Your web site is deployed on several countries. The behaviour of the page you want to test (e.g. sign up) is mostly the same across countries, however some business rules change per country.
  • You are using the PageObjects pattern to encapsulate the details of each page. You want to avoid duplicated code.
Categories
Technology

How to build a Docker image ready to run Cypress tests

My team decided to build a Docker image that contained Cypress, dependencies and all our end-to-end (E2E) tests.

Categories
Work

Automation prioritisation using Risk Mapping

Scenario: My team wanted to write more automated checks, but we had too many features to cover and not enough time. We had to prioritize what to test… but how to do it objectively?

Categories
Technology

Cloudflare + Hosting + Gmail

How to keep using your hosted email on Gmail, after migrating to Cloudflare