Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Changing the Game with Cypress

Changing the Game with Cypress

When we talk about UI tests, the first thing that comes to mind is probably Selenium. No wonder, it's the most widely used testing framework for web applications. It was originally developed in 2004 and now, after 14 years, it is still hard to implement it correctly. Tests are often flaky, painful to debug, and the overall developer experience is rather poor. But for many years there wasn't another choice, until Cypress was born. Cypress tries to solve the biggest testing challenges, e.g. painless setup, easy to write tests, support for async testing, performance, and a good understanding of why tests fail. Cypress is made from scratch focusing on developer experience, debugability and consistency.

In this talk, we'll look at how to get started with Cypress and dive into some basic tests. We'll also see how to work with http requests, access the Local Storage and explore the debugging capabilities of Cypress.

Links:
https://github.com/d3lm/todomvc

Dominic Elm

August 10, 2018
Tweet

More Decks by Dominic Elm

Other Decks in Programming

Transcript

  1. Changing the Game with TESTING IN A WAY THAT WAS

    NEVER POSSIBLE BEFORE @elmd_ NG-Talks
  2. What are the biggest challanges you want solved? SETUP Having

    sane configuration Less hassle to set up Frictionless test setup Being easy to set up … Source: Brian Mann - Testing The Way It Should Be WRITING Simplier to write Fast and reliable Testing responsive design Visually see what broke … MANAGEMENT Flaky Easy to maintain Understand test failures Less brittle to changes …
  3. WHAT TO EXPECT • Understanding the key difference between Selenium

    and Cypress • Getting started with Cypress • Write some basic tests • Working with HTTP and the DOM • Explore debugging capabilities
  4. What is Cypress? • Cypress is an electron-based E2E test

    runner • The goal is to revolutionize E2E testing • Cypress allows for flake-free and reliable tests that run inside the browser • It provides a powerful debugging tools and rich UI • All-in-one solution that uses a good set of testing libraries
  5. Selenium vs. Cypress (1) Selenium Cypress Configuration Browser Support Open

    Source Architecture Remote commands across the network Runs inside the browser and uses Node for anything outside of the browser
  6. Selenium vs. Cypress (1) Selenium Cypress Configuration Browser Support Open

    Source Architecture Remote commands across the network Runs inside the browser and uses Node for anything outside of the browser
  7. Selenium vs. Cypress (1) Selenium Cypress Configuration Browser Support Open

    Source Architecture Remote commands across the network Runs inside the browser and uses Node for anything outside of the browser IE11 comes next
  8. Selenium vs. Cypress (1) Selenium Cypress Configuration Browser Support Open

    Source Architecture Remote commands across the network Runs inside the browser and uses Node for anything outside of the browser IE11 comes next
  9. Selenium’s Architecture Ruby C# Java PHP JS Other Bindings (Client)

    Chrome Safari IE FF Edge Other WebDriver (Server) BROWSER JSON «controls» via HTTP via HTTP
  10. Cypress’s Architecture Browser RUN LOOP Cypress App Cypress via Websocket

    Node.js Process OS DOM Service Worker … LocalStorage Window
  11. Selenium vs. Cypress (1) Selenium Cypress Debuggability Speed Waiting for

    Elements Parallelism ⏳ ⏳ Headless Browser ⏳ Multiple Browsers / Tabs
  12. Selenium vs. Cypress (1) Selenium Cypress Debuggability Speed Waiting for

    Elements Parallelism ⏳ ⏳ Headless Browser ⏳ Multiple Browsers / Tabs Comming in 3.1
  13. Selenium vs. Cypress (1) Selenium Cypress Debuggability Speed Waiting for

    Elements Parallelism ⏳ ⏳ Headless Browser ⏳ Multiple Browsers / Tabs Comming in 3.1
  14. What I ❤ about Cypress • Super intuitive and easy

    to use • No flaky tests (waits for XHR requests and DOM elements) • Rich UI and lots of debugging capabilities (screenshots and videos) • One step install (all in one solution) • Open source • Documentation
  15. What I ❤ about Cypress • Super intuitive and easy

    to use • No flaky tests (waits for XHR requests and DOM elements) • Rich UI and lots of debugging capabilities (screenshots and videos) • One step install (all in one solution) • Open source • Documentation
  16. References • Images from https://www.pexels.com/ and https://unsplash.com/ • cypress.io •

    Cypress vs. Selenium, is it the end of an era? - Lyudmil Latinov • Testing the way it should be - Brian Mann • Painless Testing for React Applications - Gleb Bahmutov