#Setting up Jest (https://jestjs.io/docs/getting-started) npm install --save-dev jest npm install --save-dev @types/jest
Generate a basic configuration file npm init jest@latest
Choose the test environment that will be used for testing - jsdom(browser-like) code-coverage - (babel)
set moduleNameMapper to { '\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '/mocks/fileMock.js', '\.(css|less)$': '/mocks/styleMock.js', },
Create folder mocks and under this folder create two files :
- fileMock.js (file content : module.exports = {})
- styleMock.js (file content : module.exports = {})
install react testing library npm i -D @testing-library/react npm i -D @testing-library/jest-dom
set module = "nodenext" in tsconfig.json