question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jest tests fail on RN 0.58 (due to Jest Transpiling issue?)

See original GitHub issue

This 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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:13

github_iconTop GitHub Comments

6reactions
seanhenrycommented, Feb 8, 2019

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:

import React from 'react'
import { View } from 'react-native'

export default () => <View />

export const Circle = () => <View />
export const Ellipse = () => <View />
export const G = () => <View />
export const Text = () => <View />
export const TSpan = () => <View />
export const TextPath = () => <View />
export const Path = () => <View />
export const Polygon = () => <View />
export const Polyline = () => <View />
export const Line = () => <View />
export const Rect = () => <View />
export const Use = () => <View />
export const Image = () => <View />
export const Symbol = () => <View />
export const Defs = () => <View />
export const LinearGradient = () => <View />
export const RadialGradient = () => <View />
export const Stop = () => <View />
export const ClipPath = () => <View />
export const Pattern = () => <View />
export const Mask = () => <View />

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found