我有一个像这样定义的函数:
renderItem() => <Text onPress={() => console.log('hi)}>Click</Text>
当我调用此方法时,我想声明返回的值是正确的:
expect(renderItem()).toEqual(<Text onPress={() => console.log('hi)}>Click</Text>)
不幸的是,断言失败并出现此错误:
expect(received).toEqual(expected)
Expected value to equal:
<Text onPress={[Function onPress]}>Click</Text>
Received:
<Text onPress={[Function onPress]}>Click</Text>
Difference:
Compared values have no visual difference.
如何正确测试?