Cypress VS Playwright
Tags
What is Cypress?
Cypress is a famous and easy-to-use e2e framework for testing applications as a user Using javascript or typescript language.
What is Playwright?
Playwright is an open-source End-to-End (E2E) automation framework that supports multiple languages, such as TypeScript, JavaScript, Python, and C#.
Playwright exposes a high-level API to interact with the web browser in a fast and stable way.
Demo:
Here we have points about cypress and playwright to draw a conclusion later.
Playwright and Cypress strengths:
- Handling API calls, both Playwright and Cypress are possible. What changes and how to do them.
- Cypress and Playwright's reports are good, Playwright has multiple ways to make reports and consult, we can see more in the documentation
Doc Reporters but it needs knowledge and configuration to a good reporter. With Cypress, we already have everything ready on the dashboard easily. Perhaps Cypress is better because it is easier to consult here.
- Cypress and Playwright have a good debug, but cypress we have at runtime in headed(interface mode), with playwright we need to activate it
by calling each time, this makes playwright faster, but the debug ends up being very similar to that of Cypress. I think at this
point we have a tie.
Playwright example debug:
- To wait for assertions, Cypress already does it by default, Playwright needs an await for that, it works very similar to pure JS/TS.
Cypress strengths:
- The learning curve is very basic and easier than Playwright.
Playwright's strengths:
- Playwright can do all the assertions that cypress does, only with more processing speed.
- By default, tests will be run on all 3 browsers, chromium, firefox and webkit using 3 workers. This can be configured in the
playwright.config
file.
(headless mode, but we can open any windows with different browsers in interface mode). (Cypress only runs in 1 browser at a time)
- Cypress has some issues when testing new tabs. Playwright has an api to handle a new window and tests better than Cypress.
- We have a tag called parallel to put in describe, so running all tests(it) in parallel, this is optional and we don't have it in Cypress.
This would be useful to not repeat setup helpers in before.
- To test iframe with cypress, we need a plugin, not Playwright, we test with it.
- About tests in event browsers. Playwright communicates with the browser using a websocket server, while Cypress is injected inside the browser and automates the
app from there. Handling native browser events might be more complicated then and it has proven to be the case in this round.
- We have multiples languages to use with Playwright.
Conclusion
If you are a beginner with testing and are looking for ease of installation and usage, then Cypress is the way to go. However, if you are more experienced and want to test Webkit browsers or your tests tend to have more coverage across multiple domains and pages then Playwright is the right choice.