Cypress — Is it a great start?

Kishor Munot
Dec 7, 2021 · 4 min read
Cypress Automation tool

Hello Readers,

Everyone knows about Selenium Web Driver, Robotium, Cucumber, and many more who are helping to automate our test suits. These tools are now well established in the automation industry and everyone is building their framework with the help of the above tools. Today we are going to talk about a new tool called cypress.io who is rapidly improving and helping so much to automate test cases.

Cypress framework is a JavaScript-based end-to-end testing framework built on top of Mocha — a feature-rich JavaScript test framework running on and in the browser, making asynchronous testing simple and convenient. It also uses a BDD/TDD assertion library and a browser to pair with any JavaScript testing framework.

Cypress IO is a user-friendly test automation tool for end-to-end testing, UI testing, regression suites, and integration and unit testing. It’s simple to install and doesn’t require any changes to your code. Cypress prides itself on writing tests quickly and in real-time as you build your web application. It is free to use and is provided under the MIT license. The Cypress Dashboard is a SaaS web app that pairs with our open-source Test Runner, making it easy to scale your test runs and debug failed tests.

Two primary features developed specifically for Cypress framework are:

  • Automatic waiting — Cypress waits for the elements to become visible, the animation to complete, DOM to load, the XHR and AJAX calls to be finished, etc. Hence, there is no need for implicit and explicit waits to be defined.
  • Real-Time Reloads — Cypress is intelligent enough to know that after saving a test file (xyz_spec.js file), the tester is going to run it again. So, it automatically triggers the run next to the browser as soon as the tester saves their file. Hence, there is no need to manually trigger the run.

Features of Cypress Framework

  • It waits to execute the test command automatically and enacts assertions before executing the next commands to be run.
  • It captures screenshots during test case execution to help with debugging.
  • It debugs test execution more efficiently since it provides the interactive test execution with Test Runner and logs.
  • Because of architectural design differences from other test frameworks, it provides users with faster and more reliable test execution.

Installation of cypress.io

Operating System

Cypress is a desktop application that is installed on your computer. The desktop application supports these operating systems:

  • 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 (64-bit only)

Node.js

If you’re using npm to install Cypress, please make sure below version of node.js

  • Node.js 12 or 14 and above

Then, install cypress on the project path.

cd /your/project/path

Install cypress

npm install cypress --save-dev

open cypress[Test Runner]

./node_modules/.bin/cypress open

Note: npx is included with npm > v5.2 or can be installed separately.

npx cypress open

After a moment, the Cypress Test Runner will launch.

The Cypress Test Runner attempts to find all compatible browsers on the user’s machine. The drop-down to select a different browser is in the top right corner of the Test Runner.

TestRunner

Cypress includes the following features:

  • Time travel: Cypress takes snapshots as your tests run
  • Debugging: Readable errors and stack traces make debugging easier
  • Automatic waiting: Automatically waits for commands and assertions before moving on
  • Spies, stubs, and clocks: Verify and control the behavior of functions, server responses, or timers
  • Network Traffic Control: Control, stub, and test edge cases without involving the server
  • Screenshots and videos: View screenshots were taken automatically on failure, or videos of your entire test suite when run from the CLI
  • Cross-browser Testing: Run tests within Firefox and Chrome-family browsers (including Edge and Electron) locally

Cypress is a tool that helps in web automation. In the next blog, we will discuss which tools to choose from Selenium and Cypress to experience better automation as Selenium is completely established and Cypress tool is new in the automation industry. So should we choose a tool that does new things better or is fully established?

Until then you can install Cypress and explore the tool and share your feedback about it and the good news is, you can appreciate the blog up to 50 shots and share your valuable feedback with us.

Thank you.

nonstopio

A Bespoke Engineering Studio