Cypress setup

Guide on installing Cypress and setting up e2e testing environments

This guide will:

  1. Install Cypress
  2. Set up e2e testing environments in dev and uat
  3. Provide other useful information for writing and running tests locally and in pipeline

please refer to Cypress’s official docs for more info about installation.

Prerequisites

Cypress e2e tests repo in gitlab uses yarn for installing Cypress, running tests etc. please do not use npm.

docker is not used for running Cypress, dependencies are installed by running yarn install:

Installing Cypress

  • Clone the e2e test repo in gitlab into your Workspace folder:
    • git clone git@gitlab.com:intellihr/engineering/cypress-e2e-tests.git
  • Get into the cloned cypress-e2e-tests folder
    • cd cypress-e2e-tests
  • Run yarn install to install dependencies

Set up .env file in dev and uat

  • Get a copy of .env.uat and .env.dev files from 1 password and either copy the content or change the one you need to .env file. Cypress will only look at the .env file for its configuration.

  • Please update the configcat entry with your own token on the env file Configcat Token

  • Make sure to update the .env file with your own GitLab profile token on the env file Gitlab token

  • If you want to run automated test against code that is still in DEV (not yet pushed to UAT), use the .env.dev configuration.

  • If you want to run automated test against code that is already in UAT, use the .env.uat configuration.

Running Cypress with Docker

  • Run docker compose run --rm local yarn to install dependencies
  • Run docker compose build to build your local
  • Run docker compose run --rm local open to run cypress with UI Test Runner
  • On the right corner of Cypress window, make sure Electron browser is selected
  • Click on one of the test files on Cypress window, for example, analytics-high-1.spec.ts to run the test file

Running Cypress without Docker

  • Run yarn run cy:open-intelliHR to open Cypress
  • On the right corner of Cypress window, make sure Electron browser is selected
  • Click on one of the test files on Cypress window, for example, analytics-high-1.spec.ts to run the test file

Other useful information

Scripts for running Cypress are in package.json file.

All test files are in the “integration” folder and all function files are in the “support” folder.

Other useful information can be found in notion

  1. How to run Cypress locally
  2. Automated test guidelines
  3. Cypress pipeline via Jenkins
  4. Cypress Tips and Tricks
  5. How to add new login details for Cypress Jenkins
  6. Q&A page

Troubleshooting

When run Cypress locally in Windows, if you have the following error

It looks like this is your first time using Cypress: 8.3.1
→ Cypress Version: 8.3.1 Cypress failed to start.
This is usually caused by a missing library or dependency.
The error below should indicate which dependency is missing.
https://on.cypress.io/required-dependencies

Delete the folder of node_modules and re-run yarn install.

When run Cypress locally in Ubuntu, if you have the following error

[288052:0915/163834.069605:warning:vaapi_wrapper.cc(588)] VAAPI video acceleration not available for swiftshader`
[288052:0915/163834.069804:ERROR:gpu_init.cc(440)] Passthrough is not supported, GL is swiftshader

turn on your hardware resource