router-act

Test Next.js router behavior with act and LinkAccordion.

Updated Apr 7, 2026
One-click install
npx skills add https://github.com/villa1/backupshop --skill router-act-villa1
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: router-act
Source: https://github.com/villa1/backupshop/tree/main/.agents/skills/router-act
Command: npx skills add https://github.com/villa1/backupshop --skill router-act-villa1

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing and maintaining end-to-end tests for Next.js router interactions can be flaky due to timing of prefetches, navigations, and segment-cache behavior. This skill provides a structured approach to using createRouterAct and LinkAccordion to instrument router activity, control data flow, and assert on responses in a stable scope.

Core Features & Use Cases

  • Deterministic router testing with createRouterAct to observe prefetch and navigation responses.
  • Guidance on using LinkAccordion to control when links trigger prefetches and navigations within an act scope.
  • Techniques for validating segment-cache timing with fake clocks and predictable assertions across navigations.

Quick Start

Run an act scope to assert router behavior and prefetch timing with LinkAccordion.

Frequently Asked Questions about router-act

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix flaky Next.js router tests caused by prefetch timing?

Next.js router testing becomes deterministic by using createRouterAct to observe prefetch and navigation responses within a controlled act scope, eliminating timing flakiness. This approach instruments router activity to stabilize test assertions.

What is the best way to test segment-cache behavior in Next.js applications?

Testing segment-cache semantics requires fake clocks and predictable assertions across navigations to validate timing. Using createRouterAct with LinkAccordion provides structured control over data flow and cache behavior validation in a stable scope.

How do I control when Next.js links trigger prefetches in e2e testing?

LinkAccordion controls when links trigger prefetches and navigations within an act scope during e2e testing. It works with createRouterAct to instrument router activity and assert on responses in a deterministic test environment.

Can I use Playwright for deterministic Next.js router behavior testing?

Playwright e2e testing of Next.js router behavior is supported through act scopes and LinkAccordion. This combination enables control over internal router requests, prefetch timing, and segment-cache semantics across navigations for stable test execution.

Why do my Next.js e2e tests fail intermittently during navigation?

Intermittent e2e test failures during Next.js navigation stem from unpredictable prefetch and segment-cache timing. Applying createRouterAct with fake clocks and fixtures instruments router activity to ensure deterministic assertions and avoid flaky results.