Writing unit tests for Next.js apps

A unit test is a software testing method when modules and other granular parts of source code are tested independently in order to determine the correctness of their implementation. The key point of unit tests is that they should be small, cheap to run, and isolated. And there could be a ton of them to provide good coverage.

Writing unit tests for JavaScript nowadays is easier than ever before. With modern tools, the setup takes a few minutes and you can start getting the benefits right away. This includes coverage out of the box.

For this example, we will be using Jest and Enzyme – one of the most widespread frameworks for testing React apps. Jest provides a test runner and assertion engine, and Enzyme ...

Get Next.js Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.