Testing

Three chapters have covered the mechanics: the built-in runner and mocking in Built-in Test Runner, React Testing Library 221,825 in Testing React Applications, Supertest 14,405 against an Express 24,430 API in Observability and Testing. What changes here is the subject. A Next.js 10,514 route is not a function you import and call — it is a file the framework compiles twice, renders on a server, serializes into an RSC payload and hydrates in a browser. A Server Action is not an exported function either; it is an endpoint the compiler generates.

So the questions are which half of a page a unit test can reach, and what the production build catches that no suite does. Every example ran against a create-next-app@16.3.5 project with Vitest 5.0.1 102,989 , Jest 30.5.2 62,362 , MSW 2.15.0 668,066 and Playwright 1.63.0 26,280 .

Subsections