5

25 reasons to choose Playwright as your next web testing framework

 2 years ago
source link: https://www.marcusfelling.com/blog/2022/25-reasons-to-choose-playwright-as-your-next-web-testing-framework/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

25 reasons to choose Playwright as your next web testing framework

I wanted a place to capture a list of highlights that make Playwright awesome. Here it is, in no particular order:

  1. Supports testing scenarios for multi-tab, multi-user, multi-origin/domain, and iframes. “Playwright is an out-of-process automation driver that is not limited by the scope of in-page JavaScript execution”
  2. Uses the concept of browser contexts (equivalent to a brand new browser profile) to run tests in isolation with zero overhead (super fast!).
  3. VS Code extension has features to run tests with a single click, debug step by step, explore selectors, and record new tests (codegen).
  4. HTML report to view execution results in your browser. Includes visual diffs, and artifacts like traces, error logs, video recordings, and screenshots. The entire report is a self-contained page that can be easily hosted anywhere.
  5. Fastest test execution time in Checkly’s benchmarks versus Cypress, Selenium, and Puppeteer.
  6. Built-in toMatchScreenshot() to support visual regression testing, with recent improvements such as disabling animations and masking elements.
  7. Parallel test execution is supported locally, or remotely for grids such as Selenium Grid. In addition, you can shard tests between machines to run different tests in parallel e.g. using a GitHub Action CI job matrix.
  8. Async test code uses standard JavaScript async/await syntax.
  9. Cross-browser compatibility for Chromium, Chrome, Microsoft Edge, Firefox, WebKit.
  10. Built and maintained by Microsoft ♥️ Ok, I’m probably being biased here 😄
  11. Supports TypeScript out of the box (no transpilation required).
  12. Tracing that helps with troubleshooting test runs in a post-mortem manner. This works great to repro failed CI tests.
  13. Re-use signed-in state so tests can start as a logged-in user, saving time.
  14. Emulation for mobile devices, user agents, locales & timezones, permissions, geolocation, and dark/light mode.
  15. Works well with the white-box testing approach to prioritize user-facing attributes like text, instead of CSS selectors that can change frequently.
  16. Support for API Testing, to do things in your e2e test like set up data or assert things like response code == 200.
  17. Stub and mock network requests with network interception.
  18. Actions have auto-waiting built-in, so you don’t need to rely on hard-coded sleep commands that can cause flakiness and slow down tests. Also has custom waits such as until an element is visible, or until a pop-up is loaded.
  19. Support for recording user actions as Playwright test code aka Test Generator, that can be run via CLI or the record button in VS Code.
  20. Supports device-specific events like hovering with mouse, tapping on mobile, and keyboard shortcuts.
  21. Upload and download files supported out of the box.
  22. The magic of Locators eliminates flakiness caused by dynamic controls.
  23. Playwright Test uses the same Expect assertion library as Jest which will be familiar to many JS devs.
  24. Supports tagging of tests so you can run groups of related tests e.g. `@priority=high`, `@duration=short`.
  25. Provides docker images that have dependencies and browsers baked in. This makes CI configuration simple and fast.

Did I miss anything? Post your thoughts in the comments…

Happy testing!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK