React native 不变冲突:addComponentAsRefTo jest react native

React native 不变冲突:addComponentAsRefTo jest react native,react-native,enzyme,jestjs,React Native,Enzyme,Jestjs,我正在尝试测试以下描述块,但出现错误: 不变冲突:addComponentAsRefTo(…):只有ReactOwner可以有引用。您可能正在向未在组件的render方法中创建的组件添加引用,或者您已加载多个React副本 import 'react-native' import React from 'react' import renderer from 'react-test-renderer' jest.mock('react-native-intercom', () => 'I

我正在尝试测试以下描述块,但出现错误:

不变冲突:addComponentAsRefTo(…):只有ReactOwner可以有引用。您可能正在向未在组件的
render
方法中创建的组件添加引用,或者您已加载多个React副本

import 'react-native'
import React from 'react'
import renderer from 'react-test-renderer'

jest.mock('react-native-intercom', () => 'Intercom')
jest.mock('react-native-push-notification', () => {
  return {
    configure: () => 'none'
  }
})
jest.mock('react-native-udp')
jest.mock('react-native-uuid')
jest.mock('react-native-localization')
jest.mock('react-native-google-signin', () => 'GoogleSignin')

import { Login } from '../'

describe('Containers',  () => {
  it('renders component correctly', () => {
    const tree = renderer.create(
      <Login  />
    ).toJSON()
    expect(tree).toMatchSnapshot()
  })
})
import'react native'
从“React”导入React
从“反应测试渲染器”导入渲染器
jest.mock('react-native-intercom',()=>'intercom')
jest.mock('react-native-push-notification',()=>{
返回{
配置:()=>“无”
}
})
jest.mock('react-native-udp')
jest.mock('react-native-uuid'))
jest.mock('react-native-localization')
jest.mock('react-native-google-sign',()=>'googlesign')
从“../”导入{Login}
描述('容器',()=>{
它('正确呈现组件',()=>{
const tree=renderer.create(
).toJSON()
expect(tree.toMatchSnapshot())
})
})
我试图寻找许多不同的指南,但无法使其工作。讨论中的组件正在使用引用,但通常不会出现问题。我试图删除所有重复的react-native、react或任何其他可能的react源,但没有成功


在我的项目中,我确实有酶,我也试着用它来记录快照,但是需要一个文档。“浅层”和“渲染”选项在使用“酶”时确实有效,但我想使用最全面的解决方案来测试组件是否有效。

我在项目中也遇到了同样的问题。我有一个想法,如果这是有关符号链接。您使用的是pnpm还是纱线工作区?