首页 > 解决方案 > 模拟反应导航共享元素的正确方法

问题描述

SharedElement我想通过从 react-navigation-shared-element获取与组件相关的错误来运行我的测试

我的模拟是这样的:

jest.mock('react-native-shared-element', () => {
      return () => ({});
});
    
jest.mock('react-navigation-shared-element', () => {
   return () => ({
      createSharedElementStackNavigator: jest.fn(),
   });
});

当我运行测试时:

Warning: React.createElement: 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.

标签: react-nativejestjs

解决方案


推荐阅读