Cypress — Installation and Execution

An introduction on how to install and execute Cypress

Introduction

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

System Requirements

  • 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

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

  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

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

Front-end Developer