---
title: "Better world by better software"
url: https://daily.dev/posts/better-world-by-better-software-h1ajuzlat
source_url: https://glebbahmutov.com/blog/when-it-reloads
type: article
source: "Gleb Bahmutov"
published: 2026-06-17T18:21:40.403Z
updated: 2026-06-17T18:22:00.611Z
tags: ["testing", "dom", "cypress"]
reading_time: 4
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Better world by better software

**[Gleb Bahmutov](https://daily.dev/sources/glebbahmutov)** · 4 min read · 0 upvotes · 0 comments

## Summary

When writing Cypress end-to-end tests for client-side rendered apps with delayed navigation, you can encounter a 'subject is no longer attached to the DOM' error. This happens when the URL changes immediately but the component re-renders after a delay, causing Cypress to find and interact with a stale element. Three fixes are presented: (1) asserting the new component is visible in the DOM before proceeding, (2) using a custom `prepareForReload` command that compares element references before and after navigation, and (3) using `Cypress.dom.isDetached` to detect when the old element detaches before retrying the interaction.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://glebbahmutov.com/blog/when-it-reloads>

## Similar posts on daily.dev

- [Better world by better software](https://daily.dev/posts/better-world-by-better-software-afxfv6uwc) · Gleb Bahmutov · 0 upvotes · 0 comments
- [Testing Vue components in the browser](https://daily.dev/posts/testing-vue-components-in-the-browser-dpapbjehk) · Julia Evans · 3 upvotes · 1 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#dom](https://daily.dev/tags/dom), [#cypress](https://daily.dev/tags/cypress)

[View this post on daily.dev](https://daily.dev/posts/better-world-by-better-software-h1ajuzlat)
