In my previous blog post Branded Types I have shown a useful technique for representing time durations as "branded types" which removes the confusion between seconds and milliseconds. 1 2 3 4 // value is in seconds const duration = 1 // oops, I thought the duration was in milliseconds cy.wait(duration) Let me show an other example: representing user phone numbers using branded types. This solves a common problem in end-to-end tests where the system has to verify the user to avoid scammers: 1 2 3 4 // are these numbers the same? const phoneNumber1 = '+1 (123) 456-7890' const phoneNumber2 =…
Well, I am happy to report Cypress-the-company is all in on test auto-healing in its new cy.prompt command (which I recreated locally as cypress-think plugin). Let's look at the screenshots Cypress put in the blog post: The test shows Cypress auto-healing in practice. The test had a prompt like "Turn on dark mode", which used to resolve to some button (unclear). Now the button is gone, but the test has been "auto-healed" to find another button. We can see the details of the healing by clicking on the "Turn on dark mode" step in the Command Log: Please do not use any auto-healing in your…
Using The New NPM OIDC Trusted Publishing Workflow At the end of 2025, NPM registry revoked all personal NPM tokens that I used to publish new NPM package releases. This change improves the security of the entire NPM publishing workflow, but has disrupted my CI process. For example, the new feature of cypress-timestamps has not been released, failing with the error "SemanticReleaseError: Invalid npm token.". Hmm, what do we do now? We could use publish to NPM using local npm CLI commands, entering the 2FA token, etc. But I really hate this idea. I have more than 400 NPM packages, so the…
processgithubexcerpt only · body stays at the source
Cypress-the-company is putting a lot of effort behind its cy.prompt command (which I recreated in cypress-think), so let's see if it is any good. I took a simple login form and tried to create a test using three different approaches: coding in VSCode using "update the test / Cypress reruns it / update the test" using cy.prompt command from text recording user actions using Cypress Studio TLDR; only normal coding works reliably Coding by hand Here is the "normal" login test: we grab the username (not a secret) and password (secret) and enter them into the login form. cypress/e2e/spec.cy.js1 2…
Every individual item sold on Mercari.com has an id that looks like m<number>. The item's id is visible in the URL, for example www.mercari.com/us/item/m73702188949/. If you buy several items from the same seller, you get a discount because you buy it as a bundle. Every bundle has its own unique id that looks like b<number>. Both ids are strings, yet they have a certain format that differs. In our tests we don't want to be confused which type we are passing: is it an item id; a bundle id; a random string we pass as id by mistake? Here is where TypeScript string template literal types come in…
Let's say you need to specify a timeout or wait in your end-to-end Cypress tests. You would use milliseconds 1 2 3 4 // try finding the "selector" elements for up to 1 second cy.get('selector', { timeout: 1_000 }) // then wait for 5 seconds .wait(5_000) For clarity, you could write a helper to convert seconds into milliseconds 1 2 3 4 const seconds = (n) => n * 1000 cy.get('selector', { timeout: seconds(1) }) .wait(seconds(5)) What happens if you accidentally forget the seconds(...) call? You still get a spec that passes your linter 1 2 3 4 5 const seconds = (n) => n * 1000 // oops, GET has a…
Imagine we are testing a web page that receives two numbers from the server and then shows their sum In the Command Log you can see the two GET /random-digit calls the web page makes to the server. The server responds with {n: ...} JSON object. The page should add these two numbers and show the correct sum How would you test this page? I see 4 different approaches 🎓 This blog post is based on the lessons from my Cypress Network Testing Exercises course. Compute the data in the test The simplest approach we can take is to look up the numbers shown on the page and compute the expected sum…
We’ve been working with MCP servers for a while, and this use case was a perfect opportunity to build out another one. What is an MCP Server? A very simple way to put it is that Model Context Protocol is an "API" that your AI tooling can use to get external data or perform actions by interacting with your application. If it's just an API, that seems very easy to implement. Let's think about our use case then. The Use Case The project is the TIL https://til.hashrocket.com/ website where we developers usually write about our own learning experiences throughout small TIL posts. So our idea with…
elixirprocessexcerpt only · body stays at the source
In the complex landscape of software development, aligning design methodologies with business needs is crucial. Domain-Driven Design (DDD) emerges as a key approach in addressing this alignment, especially in projects characterized by intricate business rules and processes. This methodology stands in contrast to traditional practices, such as embedding business logic within databases, offering a more adaptable and business-focused perspective. Section 1: Understanding Domain-Driven Design Definition and Focus DDD is centered around developing software that intricately reflects the business…
Optional Google Analytics helps us understand visits. Microsoft Clarity records masked interactions to improve the site. Optional tools stay off unless you choose them. Privacy details.