Getting Started with Cypress Installation for Test Automation
By Jash Unadkat, Technical Content Writer at BrowserStack - September 2, 2020
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 is a desktop application that users need to install in their systems. The Cypress desktop application supports the following operating systems:
- MacOS 10.9 and above (64-bit only)
- Windows 7 and above
- Linux Ubuntu 12.04 and above, Fedora 21 and Debian.
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:
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. 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, 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, refer to this sample Cypress tutorial that explains how to run Cypress tests on BrowserStack’s infrastructure.