Home Guide Getting Started with Cypress Installation for Test Automation

Getting Started with Cypress Installation for Test Automation

By Jash Unadkat, Technical Content Writer at BrowserStack -

Cypress is a purely JavaScript-based test automation tool for the modern web. As a testing tool, it is not just an alternative to Selenium WebDriver. Cypress has been developed with the intent of introducing developers to software testing – something usually left to testers and QA professionals.

For greater clarity, refer to this article on the key differences between Cypress and Selenium.

This article explains how users can install Cypress on their systems in order to get started with test automation.

Cypress Installation

Cypress is a desktop application that users need to install in their systems. The Cypress desktop application supports the following operating systems:

  1. MacOS 10.9 and above (64-bit only)
  2. Windows 7 and above
  3. Linux Ubuntu 12.04 and above, Fedora 21 and Debian.

Prerequisites:

One needs to have Node.js preinstalled in their systems as Cypress is a Node-based application. Node.js is a JavaScript runtime environment. One can download and install Node.js for a particular operating system from this official resource. The Node.js installation also covers the installation of npm (Node package manager).

Cross verify the Node.js installation by running the command: node –version in the terminal. To verify the npm version, run the npm –version command.

A user also needs to have a code editor like Microsoft’s Visual Studio Code for convenient programming and maintaining project directories.

For users using npm to install Cypress, Cypress supports Node.js 10 and above.

How to install Cypress?

There are two ways to install Cypress:

1. Using NPM

To install Cypress using the npm (Node package manager) navigate to the project directory and execute the following command:

npm init

The command above creates the package.json file. Just provide fundamental details like – package name, description, keywords, and author name.

The image below represents the final package.json file once the user fills up the details.Cypress installation Once done, run the command below to install Cypress.

npm install cypress --save-dev

The command above installs Cypress locally as a dev dependency for the particular project.

Note: Users need to ensure that they have already executed the npm init command. One must also verify the existence of the node_modules folder or package.json file in the root of the project to ensure Cypress is installed in the target directory.

For users willing to install Cypress using the Yarn package manager, navigate to the project directory, and execute the following command:

 yarn add cypress --dev

2. Downloading Cypress Directly

For users who are not acquainted with npm, yet want to instantly try Cypress, it is possible to directly download the zip file of Cypress from the CDN.

The direct download link automatically detects the user’s platform and fetches the zip file with the latest version of Cypress. Bear in mind that users that have downloaded Cypress directly won’t be able to record the dashboard. Once the zip file is downloaded, simply unzip and double click to start the Cypress application. It will start without the need for installing any dependencies.

Cypress installation is now complete.

Running Cypress Tests on Real Browsers Using BrowserStack

To gain accurate test insights and explore bugs that end users may encounter in the real world, testing in real environments is mandatory. BrowserStack allows testing teams or individual testers to execute Cypress tests across leading browsers like Chrome, Edge, and Firefox.

Using BrowserStack’s real device cloud, one can instantly get started with parallel testing using Cypress across 30+ browser versions. Refer to this quick start guide to get started with Cypress automation on BrowserStack. Additionally, one can also refer to this sample Cypress tutorial that explains how to run Cypress tests on BrowserStack’s infrastructure.

Run your first Cypress Test!

BrowserStack Logo Run Cypress Tests on 30+ Browser Versions Get Started Free