Stop Talking to Strangers: Applying the Law of Demeter to Cypress Tests
summary
Argues that deep DOM selectors cause fragile Cypress tests and applies the Law of Demeter: tests should only touch immediate contracts, not internal nodes. Builds a small React login app, uses cy.intercept to stub auth and a custom command cy.getByPrompt that calls Cypress AI to locate elements by behavior. Changes the button’s data-test-id and class during the demo; the test shows a self healed tag and still passes, proving the approach works.
AI-written summary · about
