score:1
Accepted answer
i uninstalled jest-cli which was 27+ version globally and tried to run from the local dependencies only, it is working for me now.
configured the modulenamewrapper in jest settings for common components
"modulenamemapper": {
"\\.(jpg|jpeg|png|gif|svg|yaml)$": "<rootdir>/__mocks__/filemock.js",
"\\.(css|less|scss)$": "<rootdir>/__mocks__/stylemock.js",
"^common/(.*)$": "<rootdir>/src/common/$1"
},
babel config modified as below:
module.exports = {
"presets": ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"],
"plugins": ["const-enum", ["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }],
["@babel/plugin-transform-runtime", { "regenerator": true }],
["@babel/plugin-transform-modules-commonjs"],
"@babel/plugin-syntax-jsx"]
};
dependencies updated:
"ts-jest": "^26.0.0",
"jest": "26.0.1",
tsconfig
{
"compileroptions": {
"outdir": "dist",
"module": "commonjs",
//"module": "commonjs",
"target": "es6",
"lib": ["esnext", "dom", "dom.iterable"],
"moduleresolution": "node",
"declaration": false,
"strict": false,
"noimplicitany": false,
"nounusedlocals": true,
"skiplibcheck": true,
"esmoduleinterop": true,
"allowsyntheticdefaultimports": true,
"experimentaldecorators": true,
"jsx": "react",
"downleveliteration": true,
"importhelpers": true,
"preserveconstenums": true,
"removecomments": false,
"sourcemap": true,
"baseurl": "src",
"resolvejsonmodule": true,
"paths": {
"common/*": ["common/*"]
}
},
"include": ["./*.ts", "./*.tsx", "src"],
"exclude": ["node_modules", "dist", "*.js"]
}
score:0
what's the react version? jest still not support react17.
Source: stackoverflow.com
Related Query
- Jest TypeError: Cannot read property 'bind' of undefined in JestAdapter
- TypeError when using React: Cannot read property 'firstChild' of undefined
- How to test form submission in React with Jest and Enzyme? Cannot read property 'preventDefault' of undefined
- React Jest test Cannot read property 'pathname' of undefined
- Why are these Jest tests failing? TypeError: Cannot read property 'apply' of undefined
- Cannot read property of an undefined object in a IF statement in JEST
- Jest throwing TypeError: Cannot read property 'fetch' of undefined
- TypeError: Cannot read property 'prototype' of undefined in jest test
- TypeError: Cannot read property 'forEach' of undefined jest
- JEST - TypeError: Cannot read property 'then' of undefined
- jest + enzyme: TypeError: Cannot read property 'htmlparser2' of undefined
- Jest - Test gives an error TypeError: Cannot read property 'then' of undefined
- issue using jest - cannot read property 'yyy' of undefined
- react jest unit test case TypeError: Cannot read property 'then' of undefined
- Jest and Enzyme unit test: TypeError: Cannot read property 'push' of undefined
- Error: Uncaught [TypeError: Cannot read property 'x' of undefined Jest react testing
- Jest error '' TypeError: Cannot read property 'preventDefault' of undefined "
- React testing with Jest and Enzyme @react-google-maps/api returns TypeError: Cannot read property 'maps' of undefined
- Jest testing promise in React gives TypeError: Cannot read property 'finally' of undefined
- Jest & Hooks : TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined
- React jest testing. Cannot read property 'maps' of undefined with google js api
- TypeError Cannot read property 'price' of undefined
- React Jest TypeError: Cannot read property 'baseUrl' of undefined
- TypeError: Cannot read property 'email' of undefined props using Jest and React. Why?
- Gatsby TypeError - Cannot read property 'id' of undefined
- jest TypeError: Cannot read property 'createRef' of undefined
- Jest error -- Cannot read property 'get' of undefined
- TypeError cannot read property url of undefined on strapi
- React-Redux mapStateToProps TypeError Cannot read property '' of undefined
- TypeError Cannot read property 'find' of undefined
More Query from same tag
- ReactJS: how to trigger form submit event from another event
- How to use a condition in react component within semantic ui dropdown menu component
- Add events to cloned component
- Best Practice: When to throw away unwanted data from asynchronous call
- setInterval timer not working properly in render() of ReactJS
- Passing data between react context
- Passing Data Between React Classes doesn't work
- How to change the route in component did mount
- Deploy an application with dockerised frontend and dockerise backend images
- Not working handleChange when copy & paste in React
- what is difference between using and not using call method in redux saga?
- Variable not defined in React
- ReactJS: How can I change dynamically inserted Component's data
- How to show current values for select inputs with or without React Hook Form?
- Reload an array of objects depending on search input value using React Hooks
- Unable to fetch list in react relay
- Insert text at cursor position in React
- Creating a custom action in react-admin I cannot see where to link to my dataprovider
- React and Redux: Uncaught Error: A state mutation was detected between dispatches
- rendering react on server
- How to change height of NextJS Image tag according to screen width?
- Deck.gl globe advice
- Stop accordion header toggle on button click
- `Cannot read property 'setState' of undefined` only inside the loop
- React - How to prevent parent re-render on prop change
- Issue using useRef with TypeScript
- How to implement webpack-dev-server to share cookie from server-side rendered page?
- React slide in navigation on button click
- Images are not displaying with <li> tag in map function for array object in Reactjs
- Is there a way to fix network 204 No content with Restful API in ReactJS