Last active
September 26, 2022 16:58
-
-
Save machelinos/e2f0bfe39838b5373f740585dfd63835 to your computer and use it in GitHub Desktop.
Vite - Jest initial setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
React + Vite projects | |
npm install jest babel-jest @babel/preset-env @babel/preset-react --save-dev | |
npm install @testing-library/react @types/jest jest-environment-jsdom --save-dev | |
-------------- | |
Whwen using fetch | |
npm install whatwg-fetch --save-dev | |
------------. | |
Create babrl congig babe.config.cjs | |
module.exports = { | |
presets: [ | |
['@babel/preset-env', {targets: {node: 'current'}}], | |
['@babel/preset-react', {runtime: 'automatic'}] | |
], | |
}; | |
----------------------- | |
Create jest.setup.js | |
import { fetch } from "whatwg-fetch"; | |
---------------------- | |
Create jest.config.cjs | |
module.exports = { | |
testEnvironment: 'jest-environment-jsdom', | |
setupFiles: ['./jest.setup.js'] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment