Installing Cypress

Profile picture for user devraj

You can directly download and install Cypress and do it using yarn but the recommended approach is to install Cypress with npm because: Cypress is versioned like any other dependency and It simplifies running Cypress in Continuous Integration.

Table of Content

  1. Install Cypress using NPM
  2. Install using Yarn
  3. Install Cypress using Direct Download
  4. Video Tutorial

1. Install Cypress using NPM

Step 1: Create new directory or navigate to existing directory

Step 2: Type below command

npm init

 It will ask several details. Press Enter for every question.

cypress intialize project

Step 3: Install Cypress

JavaScript

npm install cypress --save-dev

TypeScript

npm install --save-dev typescript

Here --save-dev means we want to add cypress as our dev dependency in package.json. So once your team will checkout your project the cypress will be automatically installed. Even when you execute on any continuous integration server this will be installed automatically. 

Step 4: Open Cypress

Now you can open Cypress runner from your project root  using one of the following ways:

#Using npx, note: npx is included with npm > v5.2 or can be installed separately.
$ npx cypress open

#The long way with the full path
$ ./node_modules/.bin/cypress open

# shortcut using npm bin
$(npm bin)/cypress open

Step 5: Select E2E or Component Testing

installing cypress

Step 6: Click Continue

installing cypress using npm

2. Install Cypress using Yarn

Step 1: Create folder or go to existing folder

Step 2: Type below command

yarn add cypress --dev