An introduction on how to install and execute Cypress
In this article, let’s explore how to install, configure and execute Cypress.
Following are the recommended system requirements (as of this writing):
- macOS 10.9 and above (64-bit only)
- Linux Ubuntu 12.04 and above, Fedora 21 and Debian 8 (64-bit only)
- Windows 7 and above
The preferred approach to install Cypress is via npm. When using npm, it is recommended to use NodeJS 8 or above.
On your machine, execute the following commands:
$npm install cypress — save-dev
This will install Cypress locally as a dev dependency for your project. The installed files can be found in the project’s ./node_modules directory.
In order to verify installation, check package.json file in the project; you wold be happy to see the cypress dependency in it !
There are multiple ways to open Cypress.
- You can open Cypress from your project root as below:
2. By using the shortcut npm bin
(npm bin)/cypress open
3. With npx :npx is included with
npm > v5.2 or can be installed separately
npx cypress open
4. By adding in npm scripts section in package.json, like the following:
Now you can invoke the command from your project root as follows:
npm run cypress:open
In the package.json npm scripts section, add the following statement:
Then, open a new command line and execute our Cypress test by running:
npm run cy:run
You can see that Cypress has successfully run all of your tests!
That’s all for now. Have a tranquil testing.