-
Book Overview & Buying
-
Table Of Contents
Full-Stack React, TypeScript, and Node - Second Edition
By :
In the JavaScript ecosystem, tests are run by test runners. Test runners are command line apps that will look through our project and run all the existing tests in it. For many years the most popular test runner has been Jest, and it remains the most widely downloaded overall. However, in this book we will use Vitest. Vitest was chosen because it is a modern test runner built on top of Vite, our build system. By sharing the same transformation pipeline, Vitest eliminates the separate configuration that Jest typically requires for ESM and TypeScript, and it runs significantly faster (benchmarks commonly show 3–5x improvements over Jest). Vitest is also largely API compatible with Jest, so nearly all of the patterns you learn here will transfer directly if you encounter a Jest-based project.
Let's start this section by providing a simple example of testing with Vitest.
CanDrive.test.ts. Note all tests in Vitest...
Change the font size
Change margin width
Change background colour