Often our tests need to confirm that while the application is loading its data, the web page shows specific information. For example, while the app is using GET /fruit network call to fetch the name of the fruit, the page shows "loading..." text. We can slow down the network call using cy.intercept command and confirm the loading text 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 it('shows the loading element', () => { // delay the network call for 2 seconds cy.intercept('GET', '/fruit', () => Cypress.Promise.delay(2000), ).as('loadFruit') cy.visit('/') // confirm the…
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 =…
Imagine you are building an online shopping site. Your goal is to build the best customer-to-customer site, similar to mercari.com 😉. When the user enters a new listing details. the system tries to suggest the best shipping option; the online commerce lives and dies by the shipping rates. So you want to suggest to the user the shipping dimensions and options that make sense. But sometimes there is no guess, so the shipping dimensions might be missing. Here is how it looks for our example test site: The dimensions predictions data is returned by the backend in response to POST /dimensions…
Let's take a sample Cypress project bahmutov/cypress-cloud-skill-example with recorded Cypress test runs on CI. For simplicity there is just one spec cypress/e2e/spec.cy.js with 3 passing tests cypress/e2e/spec.cy.js1 2 3 4 5 describe('Suite A', () => { it('works 1', () => {}) it('works 2', () => {}) it('works 3', () => {}) }) We run the tests using GitHub Actions .github/workflows/ci.yml1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 name: ci on: push jobs: cypress-run: runs-on: ubuntu-24.04 steps: - name: Checkout uses: actions/checkout@v7 # Install dependencies with caching # and run all Cypress…
Cypress can test the current subject using implicit assertions that I find more readable than the explicit Chai assertions. Recently I saw a Linkedin post that shows "before & after" API test using Cypress. Here is the screenshot included in the post. Right away, I want to say that the "after" test is better. It checks the response status first, then confirms the types and ranges of values, rather than hard codes the new item's id and creation date. The "after" test will probably pass, while the first test will probably fail really quickly on new runs. I like the general idea. But I think…
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…
Do not confuse negative assertion with a quick timeout. Let me get back to the testing of negative states one more time. Recently, I have read a pretty good blog post How to test that cache works with Cypress by Walmyr. A piece of Cypress test syntax caught my eye: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 cy.search(randomWord).then(() => { expect(count, `network calls to fetch ${randomWord}`).to.equal( 1, ) cy.wait('@random') cy.search(randomWord).then(() => { expect( count, `network calls to fetch ${randomWord}`, ).to.equal(1) }) }) The test above confirms that the web page caches the search…
I have described using Use Copilot Instructions And Page Objects to quickly develop end-to-end Cypress tests. This blog post gives another concrete example. You can find the source code in the repo bahmutov/copilot-instructions-example. First, I wrote a page object file to implement common TodoMVC application test commands: visit the app and wait for it to load reset the backend data to zero todos or the given number of items cypress/e2e/todomvc.po.js1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 export const TodoMVC = { visit() { cy.step('visit the app')…
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…
Read at the source
Your visit, your choice.
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.