jest failed with @expo/vector-icons

Please provide the following:

  1. SDK Version: 42
  2. Platforms(Android/iOS/web/all): All
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

I have a component containing @expo/vector-icons that’s working but failed in jest. The test is succeed when commented out the icon

Error messages

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

TestComponent.tsx

import React from "react";
import { Ionicons } from "@expo/vector-icons"
import { View } from "react-native"

const TestComponent = () => {
    return(
        <View>
           <Ionicons />
        </View>
    )
}

export default TestComponent

TestComponent.test.tsx

import React from 'react';
import TestComponent from '../../components/TestComponent';
import { render } from '@testing-library/react-native';

describe('test FacebookIcon component', () => {
  it('renders correctly', () => {
    const tree = render(<TestComponent />);
    expect(tree).toMatchSnapshot();
  });
});

package.json

"@expo/vector-icons": "^12.0.5",
"expo": "^42.0.0",
"react": "16.13.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz",
"@testing-library/react-native": "^7.1.0",

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.