$30 off During Our Annual Pro Sale. View Details »

Cypress vs. Playwright

Cypress vs. Playwright

Matija Marohnić

September 28, 2022
Tweet

More Decks by Matija Marohnić

Other Decks in Programming

Transcript

  1. Matija Marohnić Cypress vs. Playwright End-to-end testing showdown https://silvenon.com/blog/e2e-testing-with-cypress-vs-playwright

  2. My experience with Cypress

  3. Background • prior experience with tools like WebdriverIO • used

    Cypress for a long time • friendlier API • approachable • but eventually mostly for critical functionality
  4. Speed • 5 tests = 45s (locally) • compared to

    my other optimizations it became uncomfortable • started writing less tests 💔
  5. GUI 🤷

  6. GUI

  7. API • familiarity = jQuery 😔 • won’t look familiar

    to any new developers
  8. API • should = expect

  9. API • wrap objects to make assertions • another round

    of jQuery for everyone! 🍻
  10. API • synchronous…? • commands are queued to be run

    later
  11. Meet Playwright 🎭

  12. Background • new testing framework by Microsoft • haven’t used

    it in any serious projects yet • only side projects
  13. Supports WebKit • unlike Cypress, Playwright supports Safari • Safari’s

    support table can be uncomfortable, so it’s really useful
  14. Headless by default • seemed odd at fi rst •

    turned out to be a great feature • less clutter, no dashboards or browsers • run headed only when you need to debug
  15. Speed • 13 tests = 3s ⚡ • more than

    2x as many tests = 15x faster • speed is no longer an issue • started testing every square inch of my blog
  16. API • asynchronous, almost everything needs to be awaited

  17. API • at fi rst repetitive and error-prone, mistakes aren’t

    always obvious • but gives full control over execution order, more transparent
  18. API • uses Jest’s expect library for assertions, so looks

    more like a unit test • doesn’t need a Testing Library plugin, locators are powerful
  19. VS Code extension 🤯 • killer feature • makes Playwright

    really e ffi cient to use! • run a test just by clicking on it, and much more • a more balanced approach to GUI — stay in your text editor • 👨💻
  20. …and so much more!

  21. • I’m always excited to learn more about Playwright •

    it makes me want to write more tests 🥳