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 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
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