Tutorial basic Automation Cypress
How to install ?
Downloading and installing Node.js
The following steps will guide you through the installation of
Node.js:
1. Visit the official Node.js website
(https://nodejs.org/en/download/).
2. Select the Windows installer option.
3. Download the installer package.
4. Install the Node.js package by following the instructions on the
Node.js website.
Initializing the project
As a best practice, Cypress is installed in the directory where the
project is located; that way, we can be sure that the Cypress tests
belong to the project. In our case, we will create a folder
inside Documents and call it cypress-tests, then navigate to that directory
when installing Cypress. We can use the following commands in a
Windows PowerShell terminal to create the cypress-tests directory and
navigate to it:
$ cd .\Documents
$ cd mkdir cypress-tests
After these commands are run successfully, we will then launch PowerShell
and navigate to the directory that we just created with the following
command:
$ cd .\Documents\cypress-tests
After creating the directory, we will then initialize an empty JavaScript
project by running the following command in PowerShell:
$ npm init –y
This will create a default package.json file that will be used to define our
project.
Installing Cypress on Windows
We will now install Cypress using npm in our project directory with
the following command:
$ npm install cypress --save-dev
Running with Npx
npx is used to execute npm package binaries and comes with all
npm versions from version 5.2. Npx can also be installed using npm
from npmjs.com. To run Cypress using npx, you need to run the following
command:
npx cypress open
Launching Cypress using the full path
This method of launching Cypress references the installed Cypress
executable located in node_modules and works by running the executable
to open Cypress:
$ ./node_modules/.bin/cypress open