Jest tests fail on RN 0.58 (due to Jest Transpiling issue?)
See original GitHub issueThis issue might affect a lot of packages, but currently I only experiencing it with this one. I believe it’s related to https://github.com/facebook/react-native/issues/22175 and the solution is probably to update the import/exports and class arrow methods.
When running jest tests:
TypeError: Cannot read property 'default' of undefined
at new Svg (node_modules/react-native-svg/elements/Svg.js:22:369)
at constructClassInstance (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:3426:18)
at updateClassComponent (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:6550:5)
at beginWork (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:7426:16)
at performUnitOfWork (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:10996:12)
at workLoop (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:11028:24)
at renderRoot (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:11111:7)
at performWorkOnRoot (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:11985:7)
at performWork (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:11897:7)
at performSyncWork (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:11871:3)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:13
Top Results From Across the Web
Jest tests fail on RN 0.58 (due to Jest Transpiling issue?) #929
This issue might affect a lot of packages, but currently I only experiencing it with this one. I believe it's related to ...
Read more >Is this transpilation issue correctly filed against babel-jest?
I raised an issue https://github.com/facebook/jest/issues/11504 against the jest project, which I think is responsible for maintaining babel- ...
Read more >Testing with Jest - Expo Documentation
In this guide, you'll learn how to set up Jest in your project, write a unit test, write a snapshot test, and common...
Read more >Code Transformation - Jest
A transformer is a module that provides a method for transforming source files. For example, if you wanted to be able to use...
Read more >ts-jest - npm
A Jest transformer with source map support that lets you use Jest to test projects written in TypeScript. Latest version: 29.0.3, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I get this issue too after updating to 0.58.
In the meantime, I’m working around the issue adding the following to
__mocks__/react-native-svg.js
:Btw, have you looked at these? https://github.com/react-native-community/react-native-svg/issues/198
https://gist.github.com/JCMais/8302a1646ccc9759237947a66bdda8e0
https://github.com/FormidableLabs/react-native-svg-mock