3 minutes read
The Ultimate Cypress Testing Hands-on Guide Course
The Ultimate Cypress Testing Hands-on Guide Course

Cypress is one of the best web testing frameworks created so far.

With more and more new web development frameworks on the market, it’s harder and harder to find an end to end testing or integration testing framework that would work well in any situation.

In the recent years, we’ve seen a spike in web development frameworks, from Angular 1 or Angular 2, to the more popular React and VueJs, to new one like Svelte, and less popular like EmberJs and BackboneJs.

What do all these frameworks have in common? They are written in JavaScript, more recently most of the started supporting type-checking through TypeScript.

All along, developers and especially testing engineers, have been looking for web testing framework to satisfy their needs for their web application. Some of the options that I’ve personally tried are Selenium with WebDriver, Puppeteer, TestCafe and Cypress.

Most of these frameworks come with out of the box click and record functionality, which allows you to get started in a matter of minutes and create your first end to end test with assertions in no time.

Check the following video screencasts courses on how to get started with Cypress, TestCafe or Selenium WebDriver:

However, these click and record tools are nice and fun to work with, but long term, personally, I prefer writing tests on my own in an IDE, coding for complex test scenarios.

Let’s try to understand a more complex scenario. Suppose we need to test the “Change Password” functionality, inside our own application (authentication required), which is a very common scenario.

Our test will need to:

  • make an API call to get an Auth token (JSON Web Token) with a predefined user
  • add the token to the current session’s cookies (or local storage)
  • open the Change Password page
  • successfully change the password
  • check that your current session is not valid any more (session invalidation works as expected)
  • check that the new password works as expected (through API and/or Login Page)
  • check that the old password is not valid any more

This is a typical scenario where using a click and record tool might not be as useful, since you need to be able to store multiple account types for login, make the API call to login (you could use the UI, but this might be slower), store the auth token in the current session, the do the actual test and make all further assertions.

For this type of scenario, personally I would choose from two web testing frameworks: Cypress and TestCafe, they both come with pros and cons, please see full list here.

With Cypress, you can better mimic the UI interaction from a user’s perspective, whereas TestCafe has a similar JavaScript flow, where you extract the values you want to assert and can run assertions and manipulate data better with asyncs/awaits.

Since Cypress comes with a different approach on how write end to end and integration tests, I would say Cypress has a higher learning curve comparing to TestCafe.

It’s up to you which frameworks you decide to use, to better fit your needs and your team skills. Hope these frameworks will continue to evolve and make it easier and less error prone to write new tests and deliver high quality applications to end user with less and less critical issues.

Written by Bogdan Vazzolla.

LoadFocus is cloud Performance, load and stress testing tool which provides the infrastructure and the ability to run all these tests in less than a few minutes, keep history of the results, compare different runs to inspect performance improvements or performance degradation.

How fast is your website? Free Website Speed Test