Created
November 26, 2019 12:14
-
-
Save kisildev/4bc0caf26f6d84c0e935c97c74c2de7a to your computer and use it in GitHub Desktop.
Jest + Enzyme + Typescript (based on parcel)
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
1) npm i jest --save-dev | |
2) npm i @types/jest ts-jest —save-dev | |
3) create jest.config.js | |
--------------------------- | |
module.exports = { | |
"roots": [ | |
"<rootDir>/src" | |
], | |
"transform": { | |
"^.+\\.tsx?$": "ts-jest" | |
}, | |
"moduleFileExtensions": [ | |
"ts", | |
"tsx", | |
"js", | |
"jsx", | |
"json", | |
"node" | |
], | |
"snapshotSerializers": ["enzyme-to-json/serializer"], | |
} | |
--------------------- | |
4) npm i enzyme @types/enzyme enzyme-to-json enzyme-adapter-react-16 —save-dev | |
5) in jest.config.js -> "snapshotSerializers": ["enzyme-to-json/serializer"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Article - https://thetrevorharmon.com/blog/configuring-jest-and-enzyme-in-create-react-app-on-typescript