Cypress — Installation and Execution

Aswathy E G
2 min readMay 20, 2021

An introduction on how to install and execute Cypress

Introduction

Cypress is a JavaScript based test automation tool which can do end-to-end testing on anything that runs in a browser. It can be used for API testing and component testing as well.

In this article, let’s explore how to install, configure and execute Cypress.

System Requirements

Following are the recommended system requirements (as of this writing):

  • macOS 10.9 and above (64-bit only)
  • Linux Ubuntu 12.04 and above, Fedora 21 and Debian 8 (64-bit only)
  • Windows 7 and above

Installation

The preferred approach to install Cypress is via npm. When using npm, it is recommended to use NodeJS 8 or above.

On your machine, execute the following commands:

cd /your/project/path

$npm install cypress — save-dev

This will install Cypress locally as a dev dependency for your project. The installed files can be found in the project’s ./node_modules directory.

In order to verify installation, check package.json file in the project; you wold be happy to see the cypress dependency in it !

Open Cypress

There are multiple ways to open Cypress.

  1. You can open Cypress from your project root as below:

./node_modules/.bin/cypress open

2. By using the shortcut npm bin

(npm bin)/cypress open

3. With npx :npx is included with npm > v5.2 or can be installed separately

npx cypress open

4. By adding in npm scripts section in package.json, like the following:

Now you can invoke the command from your project root as follows:

npm run cypress:open

Execution

In the package.json npm scripts section, add the following statement:

Then, open a new command line and execute our Cypress test by running:

npm run cy:run

You can see that Cypress has successfully run all of your tests!

That’s all for now. Have a tranquil testing.

Reference

https://docs.cypress.io/

--

--