Skip to content

Document ending a hook by waiting for the state it opened - #109

Merged
tmashara merged 1 commit into
mainfrom
claude/issue-103-hook-assert-state
Oct 30, 2026
Merged

tmashara merged 1 commit into
mainfrom
claude/issue-103-hook-assert-state

Conversation

@tmashara

Copy link
Copy Markdown
Owner

A before hook whose click lands but does nothing (before hydration, or on the wrong element) shoots the closed state on both sides, and they match. Nothing about it looks wrong.

This adds no expect route field. A hook that throws is already a route error naming the side and hook (before hook failed on left: …), and it is never retried. So ending the hook with await page.locator(sel).waitFor({ timeout: 5_000 }) already gives "state not reached". The only gap an expect checked at shot time would close is state that the settle's scroll pass undoes after a before hook. beforeShot already covers that: open and assert there, and nothing runs between the assertion and the shot. A new key would add validation, dedupe, cache-key and error-path code for a single Playwright line, and it would only handle selector assertions.

Changes:

  • docs/scoping.md: the menu route example now ends with waitFor. A new paragraph says when to guard (optional things like a cookie banner) and when not to (the state under test). It also notes that waitFor is strict (use a unique selector or .first()), shows what a miss looks like, and says to move to beforeShot when the scroll pass could undo the state.
  • skills/renderdiff/reference.md: the hooks bullet gets the waitFor line, and the before hook failed errors row explains what locator.waitFor: Timeout means.
  • skills/renderdiff/SKILL.md: the open-menus note points to a hook that ends waiting for the open state.

Verification: npm run format:check and npm test pass (360/360). Nothing under src/ changed, so I skipped the visual tier.

Fixes #103

🤖 Generated with Claude Code

A click that lands but does nothing shoots the closed state on both sides,
and they match. A hook that ends with locator.waitFor turns that into a
route error naming the side, through the existing hook-error path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tmashara
tmashara merged commit 37b0a17 into main Oct 30, 2026
3 checks passed
@tmashara tmashara mentioned this pull request Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hook routes: fail when the expected state isn't reached

1 participant