Installing Cypress
Learn how you can get Cypress installed on your machine to get up and running with end-to-end testing.
We'll cover the following...
Now that we have a project we can work with, let’s see how you can also set up Cypress for it.
The minimum system requirements
It’s good to note that when it comes to installing Cypress, there is a minimal system requirement you need to keep in mind. Currently, Cypress supports the following operating systems:
- 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
If you are using Node, it also requires a Node.js version of 12 or 14 and above.
To install Cypress, you can install it either with a package manager — the route we will take — or by direct download.
Installation with yarn
or npm
To install Cypress via yarn
or npm
, you can run the following commands in your terminal respectively:
// Using npm
npm i cypress --save-dev
Make sure you are inside the project folder where you’ve set up the npm project.
// Using yarn
yarn add cypress --dev
Cypress will start the installation process that you can follow through your terminal. Once completed, it will create a cache for the version in your user directory, so next time you need to install it in one of your projects, the cache will make sure you don’t need to download it again.
Direct download
If you are not using Node or you just want to try out Cypress, it can also be installed through direct download.
The direct download will always get the latest version. Your operating system will also be automatically detected, so you can be sure you’re getting the right zip
. You can download Cypress at the following link:
https://download.cypress.io/desktop
Once downloaded, unzip the folder and you can run Cypress without the need to install anything else.
Running Cypress for the first time
Once installed, you should be able to see that now your project folder also contains a package-lock.json
file and a node_modules
folder with all the dependencies Cypress needs.
But Cypress comes with its own folder and configuration file as well. In order to see it, you will need to run Cypress. Go to your package.json
file, and replace your test
script with the following:
"scripts": {
"cypress": "node_modules\\.bin\\cypress open"
},
Then in your terminal, run npm run cypress
. When running it for the very first time, Cypress will create a cypress
folder at the root of your project. This is where you will be able to access all of your Cypress-related resources. It also auto-generates some sample tests for your convenience, as well as and a cypress.json
configuration file at your root directory.
Open your folder and let’s examine what other things Cypress installed for us.