Quick ViteJS React TypeScript Jest

This is a quick base code for setting up Jest tests for our ViteJS project for React and TypeScript.

NOTE: This scaffolded project is based on ViteJS React TypeScript Template.

Requirements

  • Node v16.13.0
  • Yarn v1.22.10

Setup

Install dependencies:

yarn install;

Run tests:

yarn test;

Tests

There are the main file used for testing.

Main test file:

  • src/__tests__/App.test.jsx

Mock used for images:

  • test/__mocks__/fileMock.js

Main jest config file

  • jest.config.ts

Main jest setup file to extend jest

  • jest.setup.ts