What’s new in Cypress 12?

What's new in Cypress 12

A platform for end-to-end testing of web applications, Cypress is open-source, fully featured, and easy-to-use. The number of forks (2.2K) and stars (36.6K) for Cypress, a relatively new player in the automation testing space, shows that it is gaining traction. As opposed to Selenium, Cypress is preferred by JavaScript-savvy front-end developers and automation testers. Despite this, Cypress continues to gain ground on Selenium. A comparison of Cypress and Selenium’s six-month download trends indicates the war between these two frameworks will intensify in the months to come.

This guide to Cypress 12, will tell about the latest features in the newest version of Cypress.

Let’s start with some history first.

History of Cypress

Cypress was founded in 2014 by Brian Mann and Gleb Bahmutov. Both co-founders had a background in testing and automation, and saw a need for a better tool for testing web applications. At the time, the most popular testing tools were Selenium and WebDriver, which were both difficult to use and had a number of limitations.

In response, Brian and Gleb developed Cypress as a more modern and user-friendly alternative to these tools. They built Cypress on top of Node.js and used a JavaScript-based test runner to make it easy for developers to write and debug test cases.

One of the key innovations of Cypress was its ability to execute tests directly in the browser, rather than using an external driver like Selenium. This made it faster and more reliable to test web applications, and allowed for a more seamless debugging experience.

Since its initial release, Cypress has gained popularity among developers and testing professionals for its ease of use and powerful features. It is now used by companies around the world for testing web applications, and has a strong community of users and contributors

Cypress Vs. Selenium

Cypress and Selenium are both popular tools for automated testing of web applications. However, they have some key differences that make them better suited for different types of testing:

  • Execution: Cypress executes tests directly in the browser, while Selenium uses an external driver to control a browser. This makes Cypress faster and more reliable, but it also means that it can only be used to test web applications. Selenium, on the other hand, can be used to test a wider range of applications, including mobile and desktop applications.
  • Ease of use: Cypress has a modest and intuitive interface. Selenium, on the other hand, can be more complex and requires a deeper understanding of the underlying technologies.
  • Debugging: Cypress comes with a number of built-in debugging tools, such as a time-traveling debugger and a command log, which make it easier to troubleshoot issues in your test suite. Selenium does not have these types of tools, and debugging can be more challenging.
  • Language support: Cypress uses JavaScript as its primary language, which makes it a good choice for teams that are already using JavaScript for development. Selenium supports an extensive range of languages, including Java, Python, and C#, which makes it more flexible but may require teams to learn a new language.

Ultimately, the choice between Cypress and Selenium will depend on your specific testing needs and the resources and skills available to your team.

Why Should You Pick Cypress Automation Testing Framework?

In this segment of the blog, we will have a look at why should you pick Cypress for your automation testing needs:

  • Ease of use: Cypress has a simple and intuitive interface, which makes it easy for developers to write and maintain test cases.
  • Fast and reliable: Because Cypress executes tests directly in the browser, it is faster and more reliable than other testing tools that rely on external drivers.
  • Support for modern web technologies: Cypress is built on top of Node.js and uses a modern JavaScript framework, which makes it well-suited for testing applications that use the latest web technologies.
  • Strong community: Cypress has a large and active community of users and contributors, which means there is a wealth of resources and support available to help you get started and troubleshoot any issues you may encounter.
  • Open source: Cypress is open source and free to use, which makes it an attractive option for teams on a budget or those looking for an open source solution.
  • Automatic waiting: Cypress automatically waits for elements to become available before interacting with them, which makes it easier to write test cases and reduces flakiness.
  • Network traffic control: Cypress allows you to control and manipulate network traffic, which makes it easier to test edge cases and failure scenarios.
  • Automatic retries: Cypress automatically retries failed commands, which can help to reduce the number of false positives in your test suite.
  • Debugging tools: Cypress comes with a number of built-in debugging tools, such as a time-traveling debugger and a command log, which make it easier to troubleshoot issues in your test suite.
  • Cross-platform support: Cypress supports a wide range of platforms, including Windows, macOS, and Linux, which makes it a flexible and convenient choice for teams working on cross-platform applications.

What’s new in Cypress 12?

In this section of the blog, we will look at the new updates in the Cypress Version 12.

  • Cross-Origin is now Available

Cross-origin is a feature that has been requested by Cypress users for many years is now available for everyone to use. You can visit another domain, drive the browser, and then return to your application earlier this year, thanks to Cypress’s experimental cross-origin support. Third-party authentication sites, for example, are notorious for crossing origins. In the past, Cypress tests required programmatic authentication, but that wasn’t indicative of how a real user would use the app.

Since Cypress executes your tests in a browser, visiting another site was a huge technical challenge due to cross-origin security restrictions. It took the team some time to figure this one out, but soon they nailed it. Cypress’s cy.session() support has moved from experimental to general availability with Cypress 12. In a subsequent test, you can restore a user session (storage, cookies, etc.) that is saved after authentication. As a result, each test won’t have to go through authentication, cutting down on overall test suite execution time.

Due to the removal of the experimentalSessionAndOrigin config flag, these features are no longer experimental and are available to all users. The company has addressed most of the known issues found during the experimental phase and the features are now ready to be used.

  • Test Isolation is Now Default

In Cypress 12, end-to-end tests are now isolated by default, resetting cookies, storage, and the page state before each test. The new test isolation behavior will not work with tests that require a state from the browser (like a previous cy.visit()).

Enabling test isolation encourages testers to refrain from relying on results from previous tests. The behavior will need to be disengaged for some users who want to rely on it. In order to disable test isolation, you can set global configuration and configure it per-suite.

  • The Fix for Dreaded Detached DOM Errors

A One of the biggest changes in Cypress 12 is the fix for the “Detached DOM” error, one of the oldest and most annoying issues with Cypress. As a result of DOM updates, the logic for DOM resolution has been enhanced to requery elements that may have replaced older ones. Testing will be more stable and reliable as a result. As an outcome of this change, the company have further classified Cypress commands, dividing them into distinct sub-categories for better understanding. To indicate their purpose, several commands have been labeled Assertions, Queries, and Actions. New terminology provides some guidance on how to chain commands together based on the updated terminology.

With a new API, plugin authors can create custom queries, avoiding detached DOM errors with our retry logic and reducing the complexity of making new queries.

Who uses the Cypress Testing Framework?

In modern software development practices, automated testing is essential. As the demand for fast time-to-market and stable products has increased, the need for stable test automation tools has also grown. As one of the most successful testing frameworks for web automation and UI test automation, Cypress has successfully established a place among the other testing frameworks.

As developers and quality assurance engineers test modern applications, they encounter pain points like synchronization errors and inconsistencies in testing due to elements that aren’t visible or available. For writing automated web tests, many frontend developers and automation engineers use Cypress, a JavaScript-based framework.

Many freelancer web developers and web testers rely on Cypress as an open-source framework. It is possible to solve the problems discussed above by integrating Cypress UI testing with a cloud-based LambdaTest service.

The LambdaTest platform executes and orchestrates tests in a fast, reliable, scalable, and secure manner. Users can test web and mobile apps manually and automatically across 3000+ browsers, operating systems, and real devices.

With LambdaTest, organizations are able to ensure faster developer feedback, resulting in a faster time to market. LambdaTest is trusted by more than 500 enterprises and one million users across 130+ countries.

Conclusion

It’s important to remember a few things when writing tests in Cypress. A Cypress test can access the same features as a JavaScript test. Your TypeScript tests can use any Cypress command and assertion. Secondly, writing tests in Cypress is easier with the write-only API. For most testers and developers, it is not recommended to use the read-only API.

Testing frontend applications with Cypress is a great experience. The development and testing processes can be slowed down by mistakes, however. Dealing with web servers and authentication providers could be challenging, as well as handling authentication and dealing with third parties.

LEAVE A REPLY

Please enter your comment!
Please enter your name here