Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error using 'react-test-renderer' - Cannot read property 'hasOwnProperty' of undefined

I'm trying to implement Jest in my react app, but when I import the react-test-renderer, I get the error message: TypeError: Cannot read property 'hasOwnProperty' of undefined

The only line in my App.test.jsx file is:

import TestRenderer from 'react-test-renderer'; // ES6

The full error text is:

TypeError: Cannot read property 'hasOwnProperty' of undefined

 at node_modules\react-test-renderer\cjs\react-test-renderer.development.js:177:27
 at Object.<anonymous> (node_modules\react-test-renderer\cjs\react-test-renderer.development.js:17924:5)
 at Object.<anonymous> (node_modules\react-test-renderer\index.js:6:20)
 at Object.<anonymous> (src\components\App.test.jsx:2:52)

Any suggestions?

like image 875
David Hope Avatar asked Nov 17 '25 13:11

David Hope


1 Answers

Check your react and react-dom versions. They should be either different or outdated.

like image 131
Mert Simsek Avatar answered Nov 20 '25 01:11

Mert Simsek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!