Preparing the environment
To prepare the environment, we'll take the previous code we developed in Chapter 6, React with Rematch – The Best Couple – Part II, as the base application that is going to be tested with testing libraries such as Jest and Testing Library.
To make use of these libraries, first we must install them as dev
dependencies using Yarn as we did in Chapter 6, React with Rematch – The Best Couple – Part II:
yarn add --dev jest esbuild-jest msw whatwg-fetch
We're installing some interesting dependencies. Let's explain them:
jest
: As we explained in the previous section, Jest is the most powerful JavaScript testing framework out there, with an amazing focus on simplicity.esbuild-jest
: Since we're using Vite, which usesesbuild
under the hood, an extremely fast JavaScript bundler written in Go, the recommended approach is to transform our source code in the Jest tests in the same way that our application...