src: https://egghead.io/lessons/jest-intro-to-confidently-testing-redux-applications-with-jest-typescript
npm install --save-dev jest-environment-jsdom
npm install -D jest
npm install -D @testing-library/react @testing-library/jest-dom @testing-library/user-event
npm install -D @babel/preset-react @babel/preset-typescript @babel/preset-env
npm install -D identity-obj-proxy
module.exports = {
presets: [
[
"@babel/preset-env",
{
targets: {
node: "current",
},
},
],
"@babel/preset-react",
"@babel/preset-typescript",
],
};
import "@testing-library/jest-dom"
{
"scripts": {
//...
"test": "jest"
},
"devDependencies": {
//...
},
"jest": {
"testEnvironment": "jsdom",
"setupFilesAfterEnv": [
"<rootDir>/jest-setup.ts"
],
"collectCoverage":true,
"collectCoverageFrom": [
"src/**/*.{ts,tsx,js,jsx}",
"!src/**/*.d.ts"
],
"moduleNameMapper": {
"\\.(css|less)$": "identity-obj-proxy"
}
}
}
it("this jest is working",()=>{
expect(true).toBe(true)
})
const a = 2
export default a;
npm test -- --coverage