DEV Community

poponuts
poponuts

Posted on

Why Cypress? and why not?

I know it's long overdue but like a true politician just before any election, as I have promised, here are the reasons why I wanted to refactor our "🐒-like"-slow Selenium framework into Cypress.

In my previous article, I initially intended to create a comparison table but I had a moral realisation to focus on Cypress itself as Katalon & Selenium have their own advantages and what may work for me may not work for others. There is no silver bullet in end-to-end testing, although, in my opinion, Cypress comes close to closing out the gaps.

Why not Cypress?

A.K.A. When not to use Cypress (I made it a checklist and if you tick ALL then I just saved you from wasting a few minutes of your life going through my whole write-up below)
❌ No native tagging (although, this may work if you have older versions of Cypress or this)
❌ Parallelisation (is that even a word?) is a pain if you are poor (unless you tricked your company to pay for Cypress dashboard)
❌ Only in two languages so far (Javascript & Typescript)
❌ Does not support multiple browser tabs
πŸ€‘ Your managers don’t like open-source and get perks from vendors who can sell their licensed automation products for six digits

For reference, here's a detailed list of trade-offs from Cypress team to make your excitement go away (Remember, fail fast though? It's easier to learn early it's not going to work than find out later when sweat investment has been spent).

Why Cypress?

I took the privilege of grouping them so it fits easily on your powerpoint presentation (or google slides if you are a fancy cloud-based startup).
βœ”οΈ Speed is paramount (Heaps faster than anything on Selenium Webdriver - nuff said)
βœ”οΈ Debugging is a breeze (time travel with screenshots and video recordings)
βœ”οΈ Flaky environments will be a thing of the past (Aysnc and re-tries for the win!)
βœ”οΈ Easy maintenance (smart waits, easier capturing of elements, lines of code refer to actual tests and not on firefighting the waits)
βœ”οΈ Extensive documentation (The gold standard of documentation I have seen on the net!)

Bonus

... as in make this an optional slide on your pitch deck if there are still rolling eyes and death stares from the audience

  • Unit and Component testing
  • Cross-browser tests (Chrome, Edge, Firefox, Electron - who tests on Safari, anyway?)
  • Javascript (quick learning curve for front-end engineers!)
  • Great support from the Cypress team (and growing community!) - although the framework is gaining massive following - the growth means less time to respond to queries - Well, I have suggested the team to use a community forum with moderators as compared to the chatroom-like Gitter which they use now πŸ€·β€β™‚οΈ

There you go! Just like what engineers do in stackoverflow, feel free to copy-pasta the above to justify and beg your manager and team to adopt this framework. Thank me later.

Top comments (0)