Getting started with Cypress
Overview:
In this article, I will be explaining what is Cypress and how we can install it for testing.
Prerequisites:
- Node.Js installed. (If not installed you can check this link).
- Visual Studio Code. ( Download Visual Studio Code using this link)
What is Cypress?
Cypress is a next-generation front end testing tool constructed on modern web. It is built on Node.JS and comes packaged as an NPM module. As its basis is Node.js it uses Javascript as a programming language.
Essential features of Cypress:
· Cypress provides a feature to take screenshots during the execution.
· Debugging is easy using developers tools.
· We don’t need to put waits, and sleeps because Cypress takes care of the synchronization techniques.
· Cypress provides proper error logging messages which helps us identify the script failure's cause.
· Cypress has the capability to take screenshots by default on failure.
How fast Cypress is growing:
Steps to install Cypress:
- Open visual studio code and create a new project.
- Add package.json
Note: Every cypress project has packaje.json file using which testers can use custom commands as per their use. This file makes complicated commands easy to use while creating scripts.
Steps to add package.json to our project:
- In Visual Studio Code, we need to open the terminal.
- Create your project folder using the below command
mkdir <project_name>
3. Navigate to the created folder:
cd <project_name>
4. Use the below command to create a package.json file:
npm -i init
5. Type yes and hit Enter.
6. Open the folder you have created above in step 2.
7. After opening the folder I will be getting package.json created in the folder.
Now our package.json has been added to our project. Our next aim is to add Cypress to this project.
Adding Cypress to the project:
- Run the below command to install Cypress into your project:
npm install cypress --save-dev
2. Go to package.json and verify Cypress with the version available in that file.
we are done with installing Cypress into our project. Now we can use it for testing our web application.
Conclusion:
In this blog, I have explained the steps to install Cypress and the pre requisites for installing it.
References:
About the Author:
Shubham Pandey is a Test Engineer here at Version 1.