Friday, January 15, 2021

Cypress Thrill


 Last night I attended Cypress: beyond the "Hello World" test with Gleb Bahmutov. Here's the blurb:

Gleb Bahmutov, a Distinguished Engineer at Cypress will show how to write realistic Cypress tests beyond a simple "Hello World" test. We will look at reusable commands, starting and stopping servers, running tests on CI, creating page objects, and other advanced topics. Everyone who is just starting with Cypress or is an advanced user will benefit from attending this free meetup.

I'm always interested in building up my background knowledge around test tooling so a presentation from an expert with a bit of depth but still suitable for a relative newbie seemed ideal. I also thought I could take the opportunity to practice my sketchnoting on a technical talk, something I've failed at in the past.

Last things first, then: I still found sketchnoting hard. In this area, where I know concepts but not much specific, I don't have a good instinct for the level of detail to capture. I was pleased that the notes weren't a total scribble disaster, and I can see this morning that they jog my memory, so I'm counting that as a win.

In terms of the webinar's content, my lack of hands-on experience with Cypress meant that I sometimes had no context for the points being made, or they were at a lower implementation level than I need right now. However, because the talk was essentially a series of largely unrelated tips I never fell completely out of touch.

I got some of the background material that I was looking for, too. Anyone who's been around testing for a while will have seen chatter about the relative merits of Selenium and Cypress. For example, Jason Huggins, the creator of Selenium, says things like this:

It's true, tho. Cypress' in-browser, JS-only, trapped-inside-the-browser's-security-sandbox approach is the same architecture as the first version of Selenium. We abandoned it because it turned out to be a bad idea. I wish them luck though. Maybe they'll make it work this time.

Huggins is also on this Twitter thread, where Richard Bradshaw is trying to nuance the conversation:

My main point is it’s not Selenium vs Cypress. It’s a custom framework with many other libraries vs Cypress. That makes for a better comparison and also stops many negatives aspects bing slammed on Selenium, when really it’s the other libraries or poor code/design.

Naturally, Gleb talked about ways of executing code outside the browser using Node.js and also about advantages of running inside the browser such as being able to access browser-native objects. With that capability, some of the perceived weaknesses of Cypress can be worked around, for example by overriding window.open()to capture data about links opening in  another page.

He also covered the problem of moving between multiple domains (for example when a commerce site subcontracts payment processing to a third party) where they're looking at an approach that, conceptually at least, pushes state to a stack at the point of changing domain, and pops it on return. I think this is a related ticket in the Cypress github repo.

I get a kick out of listening to people who know and care deeply about a topic. It's clear that Gleb is one of them and an hour in his company has helped me to incrementally improve my knowledge of the state of browser automation.

Gleb has made his slides available and the talk was recorded: 

https://twitter.com/FriendlyTester/status/1278343153729384449?s=20

No comments:

Post a Comment