Which framework should I choose to create my E2E tests? Cypress or Playwright?

With the constant technology evolution, IT professionals need to update themselves with the tools at their disposal, in order to improve the quality of their code, product and user experience. The “respectful” Quality Analyst values the continuous improvement of the software that is being created, and when we talk about quality, the first word that comes to mind is TESTS.

To level the tests into layers for easy understanding, we can use the test pyramid. This pyramid is separated into 3 levels, namely: Unit Tests, Integration Tests and E2E Tests. It is a graphical way of demonstrating the amount of tests to be carried out, based on the speed of its implementation with the cost and time of execution of these tests.

Unit Tests are at the base of our pyramid. We want to create a greater amount of Unit Tests compared to other types of tests, because their implementation is easy and fast, causing a reduction in the cost of the test. Integration Tests are in the middle of our pyramid, as they are more difficult to create. Last but not least, E2E Tests are at the top, opposite Unit Tests – expensive, complex and time-consuming – and we want to do it in smaller quantities. However, regardless of cost or speed, all tests have their value in the implementation of software, ensuring security and quality to your system.

The E2E Tests – “End to End” or for the most intimate “End to End” – aim to prove the system more completely, simulating the real environment in order to replicate real scenarios made by the user. Based on this principle and focusing on continuous improvement, I bring you two tools that make it possible to automate this type of test.

Cypress

Cypress is an open source framework released in 2017 as a new way to automate testing. By allowing simulation of user behavior, Cypress makes it possible to create E2E tests and component tests during software development.

With its excellent documentation, Cypress has learning facilities as it produces educational content on various teaching platforms. It can support test writing styles such as BDD and TDD, enabling the QA to build the test and observe the tests in an exclusive tab. Cypress also offers debugging features to contribute to developer productivity in terms of test writing and quality.

Tests run in real time inside a browser – like an app – during test implementation, facilitating usability and making test reports. If a test fails during its execution, Cypress makes it possible to capture images and videos, notifying us of the exact location and time when the error occurred.

But like all these possibilities, Cypress also has its flaws. The framework takes a long time to load the initial – and necessary – information to run the tests, and may lose productivity in short scenarios or smaller software. It has a unique compatibility with programming languages, that being the exclusive support for JavaScript and, as one of the biggest problems of Cypress, is its lack of support for multiple tabs and official support for downloading and uploading files.

Playwright

Created by the “Puppetter” developer team, Playwright is an open source framework released by Microsoft in 2019 explicitly for end-to-end testing.

Using a single API, Playwright has support for several programming languages such as JavaScript, Java, Python and C#, Playwright creates scenarios covering multiple tabs in the main browsers on the market (Chromium, Firefox and Webkit) and supports other test structures like Jasmine, Mocha and Jest.

With easy installation and configuration, Playwright has the ability to download and upload files in the implementation of your tests, as well as the simulation of mobile devices, geolocation and access profiles within your application, building a complete environment to simulate the experience actual user.

Not everything is rosy though, as Playwright is still a newcomer to the market, and its support and community support is still limited, as is its user base. The big problem with the framework is that it does not support IE11 and native mobile applications.

Leonardo… and what’s your conclusion?

BUUUT, now what? After summarizing the advantages and disadvantages of each framework, which one should we use? And the answer will always be… It depends.

The two tools have a similar end goal, but approach the testing process differently, depending on the specific needs of your application.

Cypress is easier to learn due to the time of launch and the amount of supporters in the current market scenario. Its support of accepting BDD and TDD in test scripts facilitates test implementation, and facilitates QA writing test reports. Finally, Cypress has a high efficiency in the structure in which it is built by the framework.

Playwright, on the other hand, proposes a much greater flexibility in its design, since it has support for several languages, several browsers and when the test scenarios have the need to use multiple tabs, downloads and uploads of files. However, community support is still limited and the lack of support for IE11 and native mobile applications may interfere with your choice.

When it comes to comparing tests between Cypress and Playwright, the key determinant for your project will be the level of flexibility (Playwright) versus your project’s structure (Cypress) for running and controlling your tests.


Posted

in

,
Leonardo Silva Avatar

by

Comments

Leave a Reply

%d bloggers like this: