Published
If you are trying to use Jest
in your Vite-React-TypeScript app
for the very first time it could get a little bit tricky. Luckly with the help
of some people on the web
we can piece together a straightforward solution.
Follow these steps for a quick and painless setup.
Installing the dependencies
There’s a couple of packages that will be needed for Jest
to work properly.
For TypeScript
support add these packages:
For Jest
& Testing Library
, add these packages:
Configuring our project
We’ll need to configure Jest
. Add a jest.config.ts
file with the following content:
To conclude, inside your package.json
add a test
script calling jest
.
Adding a simple test
Add a test file with test.tsx
as extension.
Running our test(s)
Simply run npm test
.