Migration regression tests
What you need to know
Migration regression tests compare externally observable behavior before and after a route moves. Check HTTP contracts, rendered content, navigation and freshness separately, not just successful compilation.
By the end, you can: compare status and data behavior; check navigation and cache changes.
Record an explicit regression matrix
GET /catalog -> 200, heading CatalogGET /old-books -> 308, Location /catalogGET /shelf -> 200, heading Catalog, visible /shelfGET /api/stock?slug=fern-atlas -> 200, available truePOST /api/stock -> 405, Allow GETGET /catalog/missing -> 404Expected behavior: These are staged expectations for an approved fixture; record observed values separately.
How it works
Record a baseline from a pinned production build using synthetic data and a fixed route matrix. Inspect initial HTTP responses without following redirects, then follow known redirects and compare destination content. Test direct loads, client links, back/forward, query values, dynamic missing routes, and response headers. For API migration compare accepted methods, duplicate and malformed inputs, status, content type and body, as well as denied access. A framework default such as OPTIONS or HEAD may differ, so document which behavior is required. Cache behavior needs cold, warm and post-update requests with observable source versions; browser refresh alone is not proof of invalidation. An intentionally changed route contract requires an explicit migration decision and updated clients. Rollback restores a tested previous artifact; it does not automatically undo database writes. Keep the fixture local and do not test real accounts or production endpoints. The independent contract model in this package checks expected values, not Next.js route resolution.
Compare only named contract fields
type Snapshot={status:number; location:string|null; marker:string};function sameContract(before:Snapshot,after:Snapshot){ return before.status===after.status&&before.location===after.location&&before.marker===after.marker;}const before={status:308,location:'/catalog',marker:''};const after={status:307,location:'/catalog',marker:''};console.log(sameContract(before,after));Expected behavior: false. A changed redirect status is a regression under an unchanged contract even if the destination stays the same.
Common mistake
Do not compare only screenshots or successful responses. Do not claim a mocked response proves actual migration behavior; retain negative tests, cache observation and a rollback plan.
Practice and verification
Run the pure contract-diff tests. Then prepare the actual before/after production test run, including fresh browser contexts, direct API access, missing records and warm cache. Keep planned and executed results distinct.
Scope: Proposed Next.js 16.x, React 19, Node runtime. Root-mounted Pages and mixed-router fixtures with Cache Components disabled; the basePath example is separate. Framework examples are staged, not executed. Exact patched dependencies and platform contracts pending.