Understand the limitations of App Router and Edge Runtime emulation
mainNTARH is designed for unit testing API route handlers, not for recreating the full Next.js runtime. Because of this, several Next.js features are not available:
- Middleware and
NextResponse.next() - Metadata, Static Assets, and Styling
- OpenTelemetry, Instrumentation, and Caching
- Server Actions and Mutations
- React components
- Helper functions (except:
cookies,fetch(global),headers,NextRequest,NextResponse,notFound,permanentRedirect,redirect, anduserAgent)
Important Runtime Note: While NTARH provides support for the "edge runtime", your tests will always run in Node.js (or your chosen test runner). It does not run in a different runtime, realm, or VM. NTARH should be used for unit testing handlers in addition to, not instead of, end-to-end testing.