All solutions

    By stack

    How to Test a Next.js App End to End

    Server components, route handlers, streaming, middleware — a Next.js app has a lot of moving parts between a request and the screen. Here's how to test the whole thing without a Playwright suite.

    Last updated: September 1, 2026

    The problem

    A Next.js request can pass through middleware, a server component, a route handler, streaming boundaries, and client hydration before anything is usable. Each of those is a place things can break in ways that unit tests and component tests won't catch — a server component that throws only with real data, a redirect that lands wrong, a hydration mismatch that breaks an interaction.

    Why the usual approach falls short

    • Component tests stop at the component boundary. They don't exercise the server/client round trip.
    • A Playwright or Cypress suite is a second codebase that drifts with every routing or layout change.
    • SPA-like navigation plus server rendering makes scripted E2E tests flakier — timing between server response, streaming, and hydration is exactly where fixed waits fail.

    How BlackBat AI fits

    Point BlackBat AI at your running Next.js app — a Vercel preview URL, staging, or production — and it uses it like a person: following App Router or Pages Router navigation, waiting for streamed content and hydration to settle, submitting forms that hit route handlers, and following middleware redirects. It reports broken flows with screenshots and reproduction steps, and there's nothing to rewrite when you restructure routes.

    For the flows that must always work, describe them in plain English.

    Keep Vitest and React Testing Library for logic and components — the end-to-end testing guide covers how the layers divide, and BlackBat AI vs Playwright covers the E2E-layer tool choice.

    What your first run looks like

    1. Grab a preview or staging URL and a test account.
    2. Start a run; BlackBat AI discovers routes and flows as it explores.
    3. Review findings and the navigation map; pin the critical flows as plain-English checks.

    What to cover first in a Next.js app

    Prioritize the journeys that cross the most layers of the framework:

    • Authentication through middleware. Sign-in, sign-out, and what middleware does with a logged-out visitor on a protected route.
    • Forms that hit route handlers or server actions. Validation, error states and what the page shows after a successful submit.
    • Dynamic and data-dependent pages. Detail pages, lists with empty states, and pages whose content changes per user.
    • Navigation between server-rendered and client-side screens, where hydration problems tend to show up.

    An autonomous run exercises these without a list. Then pin the flows the business depends on as plain-English checks.

    Why preview deployments suit this

    Next.js teams usually get a preview URL for every pull request. That is an ideal target: it is built the way production is, so bundling, edge and environment differences show up in the run. Trigger a run against the preview from your pipeline with an API key (paid plans), or start one on demand, and review the findings before merging. If previews are behind authentication, give BlackBat AI a test account's credentials.

    Where it fits

    Unit and component tests underneath, BlackBat AI for end-to-end coverage of the running app, a small scripted set for exact assertions. See also how to test a React app end to end.

    FAQ

    Point BlackBat AI at your app

    One URL. A map of every flow and a list of what's broken, in minutes. Free, no credit card.