【发布时间】:2019-12-30 13:31:44
【问题描述】:
我的 React Native 项目中有一个从 Component 扩展而来的类。我在其他类 render 中使用这个类,并通过它传递 screen props:
class OtherClass extend Component {
render() {
return (
<MyCustomComponent screenprops ={{number : this.state.number}}
})
}
现在我正在使用 Jest 编写测试。我能够在没有屏幕道具的情况下为组件类编写测试:
test('MyCustomComponent renders correctly', () => {
renderer.create(this.MyCustomComponent);
});
但我不知道如何测试屏幕道具并在我的测试中使用它们。 我搜索了很多,但找不到解决方案。
【问题讨论】:
标签: unit-testing react-native jestjs testng react-props