03 Cypress Setup - biswajitsundara/Cypress GitHub Wiki
- Search "node download" in google or go to https://nodejs.org/en/download/
- For windows download the installer (.msi) as per the system 32 or 64 bit.
- Once installed go to program files/node js folder and copy the path
C:\Program Files\nodejs
- Create a new environment variable under system variables
NODE_HOME
with the above path - Append the path in
Path
variable also. - Then open command prompt and type this command
node -v
- If it returns the version number like
v12.18.2
then node js is successfully installed.
- npm stands for node package manager. It's included in the Node.Js
- Open command prompt and type this command
npm -v
- If it returns the version number like
6.14.5
then node js is successfully installed.
- We can use IDE like Eclipse, WebStorm however Visual Studio Code is the best IDE for TypeScript
- This can be downloaded from here - https://code.visualstudio.com/download
- For windows OS - https://code.visualstudio.com/docs?dv=win
- Visual studio has licensing cost but the community version is free.
- Create an empty folder with name
Cypress Basics
and open the same in VS - Go to terminal and enter the command
npm init -y
this will create a basicpackage.json
file - Then enter this command
npm install cypress --save-dev
this will download the desktop & CLI version of cypress tool - Once done then enter this command to run the test runner
node_modules\.bin\cypress open
- The test runner UI will open, under examples folder, click on any spec.js file, it will start executing the script.
- Once the above steps are done, it will create a skeleton of Cypress project.
- If you see cypress.json file, folders like fixtures, integration, plugins, support etc then installation is successful.
Though we can use the command node_modules\.bin\cypress open
to open the test runner every time but it looks bit odd. So the best way is to add the command in package.json
{ "scripts": { "cypress:open": "cypress open" } }
Then to launch the test runner enter this command npm run cypress:open
To bring auto suggestions (means we type cy dot, and suggested methods should appear) in the editor we need to add below line to all the files. /// <reference types="cypress" />
however the best approach will be to create jsconfig.json
file under root folder and add the settings.
{ "include": [ "./node_modules/cypress", "cypress/**/*.js" ] }
Let's say if your company has any proxy or you are having trouble downloading through npm then you can use this approach to install cypress.
- Download the cypress zip file : https://docs.cypress.io/guides/getting-started/installing-cypress.html#Direct-download
- Give this command
set CYPRESS_INSTALL_BINARY=\local\path\to\cypress.zip
- Then use this command
npm install cypress
- Now it will not download from internet using npm, it will download from the local zip file.
If we want to format the code in Visual Studio Editor then use the keys Shift
+ Alt
+ F