本文へスキップ
Kitbay
スキル

router-act

MIT2026年11月11日 更新143,470GitHubスター

An internal skill in the Next.js repository for writing end-to-end tests that involve prefetching, client-side navigation or the segment cache.

スキルの内容

An internal skill in the Next.js repository for writing end-to-end tests that involve prefetching, client-side navigation or the segment cache. It explains the repository's createRouterAct helper, which intercepts router requests inside a scope, buffers the responses and asserts on them, so tests do not depend on exact request counts. Links are hidden behind a LinkAccordion component and revealed inside the scope so prefetches happen only when the test wants them, and the preferred assertion proves the cache served the data with no requests. It warns against polling and timeouts, reading page content before the scope ends, and going back with open accordions, and uses Playwright's fake clock for staleness tests.

できること

  • Control router prefetch timing in tests
  • Assert that the cache served a navigation
  • Test staleness with a fake clock