-
Book Overview & Buying
-
Table Of Contents
Full-Stack React, TypeScript, and Node - Second Edition
By :
Now that we've gone through Chapter 8, and our introduction to Express, we have a solid grasp of Node fundamentals. Let's now introduce testing in Node.
Just like React, there are multiple test runners available for Node, including Jest and Vitest. But in this chapter, we will use the built-in Node test runner, which became stable in Node 20. Since it ships with Node itself, there are no additional dependencies to install or configure, making it a natural choice for server-side testing. Its API will feel familiar if you've used Jest or Vitest, though as you'll see there are some notable differences.
Let's create some examples of using the Node test runner. But first, let's create a new project.
Chap9 create a new folder called test‑nodecd into the test‑node folder and initialize our project with the following command:
npm init
test‑node and accept defaults for the other package...
Change the font size
Change margin width
Change background colour