After installing cypress on windows if a user is getting the below error message to open cypress then need to perform step 1 and step 2 to resolve the cypress verification time out issue
Package.json is a file found in all npm packages and is normally found in the project root.
It contains various metadata about the project.
This file provides information to npm so that it can identify the project and handle its dependencies.
It can also contain other metadata, such as a project description, the project’s version.
A Node.js project’s package.json file is usually found in the root directory.
This example of package.json file used for writing code using cypress
{“devDependencies”: {“cypress”: “9.5.2”}}
What are devDependencies in the package.json file?
Dependencies are specified with a simple hash of package name to version range. The version range is a string that has one or more space-separated descriptions. Dependencies can also be identified with a tarball or gitUrl.
devDependencies: Packages that are only needed for local development and testing.
What is tarball?
The tarball is a compressed file format. You need to unpack it before running the npm command.
What is "dependencies" in package.json file?
"dependencies": Packages required by your application in production.
Once both cypress and Editor are available on the machine then perform the below steps.
Step 1) Open Visual Studio Code.
Step 2) Create a new folder to store the project files or Open any existing project folder to store files.
Step 3) Click on New File menu as shown below.
Step 4) Type package.json and save it.
Step 5) In Package.json file need to mention cypress for dev dependency. To do this we have multiple ways. From Terminal Menu Click on New Terminal Menu. We can use this terminal within IDE.
Step 6) Type command “npm install –save-dev cypress” on Terminal and Wait because this will search for package.json file to install the dev dependencies. so add the below code in a package.json file (use IntelliSense if require to type)
“devDependencies”: { “cypress”:”^9.1.1″ }
While writing this blog 9.1.1 was the latest version so use IntelliSense to get the latest version in place of copy-paste.
Save the file and Hit the command “npm install –save-dev cypress” on the terminal.
The terminal will display the below message after installation
PS E:\Cypress Projects> npm install –save-dev cypress npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
added 163 packages, and audited 164 packages in 49s
24 packages are looking for funding run npm fund for details
found 0 vulnerabilities PS E:\Cypress Projects>
The above command will install the latest version of cypress within your project.
All helpful methods after pressing dot in code editor are coming from node_modules -> @types -> index.d.ts file.
Step 7) How to create Cypress package
In Terminal type command “npx cypress open” and press enter.
It will show a message like this
It looks like this is your first time using Cypress: 9.1.1
Solution for the above error is Relaunch cypress one more time. If that doesn’t work then change
VERIFY_TEST_RUNNER_TIMEOUT_MS value to 100000 Which is by default is 30000. ” VERIFY_TEST_RUNNER_TIMEOUT_MS ” is available under verify.js file located “node_modules\cypress\lib\tasks\verify.js” Save the changes and type command “npx cypress open” and press enter.
After successful configuration, the user will see cypress Test runner window like below.
Step1) Open command Prompt (type cmd in search and press Enter)
Step 2) Type command ” npm uninstall cypress”
The system will start uninstalling cypress and will show the below message.
C:\Users\Admin>npm uninstall cypress
removed 163 packages, and audited 1 package in 15s
found 0 vulnerabilities
Step 3) If you get below error then try to navigate to the directory where cypress is installed from the command line
npm ERR! code EPERM npm ERR! syscall mkdir npm ERR! path E:\ npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, mkdir ‘E:\’ npm ERR! [Error: EPERM: operation not permitted, mkdir ‘E:\’] { npm ERR! errno: -4048, npm ERR! code: ‘EPERM’, npm ERR! syscall: ‘mkdir’, npm ERR! path: ‘E:\’ npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It’s possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it.”
Step 4) Navigate to the directory where cypress is installed using the cd command in the command line
Step 5) Type command “npm uninstall cypress” and press enter
After a couple of seconds, the system will uninstall cypress and will show the below message.
removed 163 packages, and audited 1 package in 6s
found 0 vulnerabilities
If you want to reinstall cypress from step 1 on windows then follow the article install cypress on windows.
To remove dependencies from the package.json file we can use the command “npm uninstall <name> –save”
This will uninstall cypress and also remove dependencies from the package.json file.
Users can install cypress on windows by giving the single command “npm install cypress”. But to run this command it is important that npm is installed on the machine.
How to check if npm is installed on the machine or not?
Navigate to command prompt and type command npm -v
If windows show any version then npm is installed on a machine. If no version is specified then follow the article to install npm on windows.
Once NPM is available on windows then type the command “npm install cypress” and press enter.
After successful installation type command “npx cypress –version” and press enter to check if cypress is installed or not.
Cypress is capable to test anything which runs on a chrome browser. The architecture surrounding Cypress is built to handle modern JavaScript frameworks.
Cypress is the best tool to automate web app built on the latest React, Angular, Vue, Elm, etc. frameworks.
Cypress is easy to install just by using the command “npm install cypress”
Do not compare cypress with selenium. Both have different architecture to identify elements. End to end Web automation is possible with cypress. Cypress can perform unit testing, Database Testing, UI Testing.
Cypress is an open-source front-end testing tool built for modern applications.
Cypress is not selenium. Cypress is built with the new architecture. Cypress uses the same run-loop in place of communicating with different drivers like selenium.
Cypress does not depend on third-party drivers.
When users want to automate any project then they have to install Frameworks like mocha, jasmine , QUnit, Karma.