Write automation tests in your
favourite language, javascript
Shabareesh JL
Biswajit Pattanayak
What is wrong with e2e tests?
● Developers hate e2e tests
● E2E tests are flaky
● E2E tests take long time to set up
● Limited debuggability
● Network traffic control
How cypress can solve this?
How it works and capabilities
● Runs in browser and in the same run loop as the application
● Taps the native browser apis and network proxy to modify the requests
so as to avoid same-origin policy
● Realtime native access to the DOM
● Cypress commands are promise alike and are asynchronous in nature
● During execution all commands are enqueued in a global singleton object
● Automatic retry ability
● Can stub or spy network requests; hence useful to simulate failure
conditions
Limitations
● Not completely open source; runs on a freemium model
● Supports only javascripts; no other language support possible
● Bound to same-origin policy
● Cross browser support is still being worked on
● Can’t run a multi tab test
● Remote execution is not possible
● If the app contains 3rd party iFrames, cypress can test those by disabling
web security or through cy.request
● Performing tasks outside the browser are little cumbersome
How we exploited it to solve our problem
Hands-on Exercise
❖ write a simple cypress test to validate a user journey
❖ understand debugging, reporting in cypress
❖ make the test suite CI ready - setting up environment configuration,
choosing browser, and recording tests
❖ stubbing in cypress to test edge cases
❖ use other important features of cypress such as making XHR request,
using plugin, writing custom commands

Cypress workshop for JSFoo 2019

  • 1.
    Write automation testsin your favourite language, javascript Shabareesh JL Biswajit Pattanayak
  • 2.
    What is wrongwith e2e tests? ● Developers hate e2e tests ● E2E tests are flaky ● E2E tests take long time to set up ● Limited debuggability ● Network traffic control
  • 3.
    How cypress cansolve this?
  • 4.
    How it worksand capabilities ● Runs in browser and in the same run loop as the application ● Taps the native browser apis and network proxy to modify the requests so as to avoid same-origin policy ● Realtime native access to the DOM ● Cypress commands are promise alike and are asynchronous in nature ● During execution all commands are enqueued in a global singleton object ● Automatic retry ability ● Can stub or spy network requests; hence useful to simulate failure conditions
  • 5.
    Limitations ● Not completelyopen source; runs on a freemium model ● Supports only javascripts; no other language support possible ● Bound to same-origin policy ● Cross browser support is still being worked on ● Can’t run a multi tab test ● Remote execution is not possible ● If the app contains 3rd party iFrames, cypress can test those by disabling web security or through cy.request ● Performing tasks outside the browser are little cumbersome
  • 6.
    How we exploitedit to solve our problem
  • 7.
    Hands-on Exercise ❖ writea simple cypress test to validate a user journey ❖ understand debugging, reporting in cypress ❖ make the test suite CI ready - setting up environment configuration, choosing browser, and recording tests ❖ stubbing in cypress to test edge cases ❖ use other important features of cypress such as making XHR request, using plugin, writing custom commands