Book Image

Next.js Quick Start Guide

By : Kirill Konshin
Book Image

Next.js Quick Start Guide

By: Kirill Konshin

Overview of this book

Next.js is a powerful addition to the ever-growing and dynamic JavaScript world. Built on top of React, Webpack, and Babel, it is a minimalistic framework for server-rendered universal JavaScript applications. This book will show you the best practices for building sites using Next. js, enabling you to build SEO-friendly and superfast websites. This book will guide you from building a simple single page app to a scalable and reliable client-server infrastructure. You will explore code sharing between client and server, universal modules, and server-side rendering. The book will take you through the core Next.js concepts that everyone is talking about – hot reloading, code splitting, routing, server rendering, transpilation, CSS isolation, and more. You will learn ways of implementing them in order to create your own universal JavaScript application. You will walk through the building and deployment stages of your applications with the JSON API,customizing the confguration, error handling,data fetching, deploying to production, and authentication.
Table of Contents (9 chapters)

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 is used as a DOM manipulation/verification/traversal tool.

Let's install everything:

$ npm install react react-dom isomorphic-unfetch...