react-native - 如何访问测试文件中的 props 值组件(Jest 和 Enzyme)
问题描述
如何访问测试文件(Jest 和 Enzyme)中组件中的 props 值?这是我的组件,我想访问测试文件(Jest 和 Enzyme)中 Pin 组件中的 prop 值,可以吗?
<View style={styles.containerForm}>
<Text style={styles.textDescriptionGreyFont}>Enter Code</Text>
<Pin testID={'input_pin'} count={4} value={otp} setCode={(code) => setOtpCode(code)} />
<View style={styles.containerResendTimer}>
{renderResend()}
<Text style={styles.textDescriptionThemaFont}>{renderTimer()}</Text>
</View>
<ButtonFull
testID={'submit_otp'}
isDisabled={false}
buttonColor={fullFilled ? color.thema : color.disabledButton}
onPress={() => submitOtp()}
title={submitting ? 'Loading ...' : 'Submit'}
/>
</View>
解决方案
我找到了解决方案,
expect(appWrapper.find('Pin').prop('value')).toBe('')
expect(appWrapper.find('ButtonFull').prop('isDisabled')).toBe(true)
推荐阅读
- javascript - Javascript D3js 饼图
- c# - 如何将值从窗口 2 中的页面传递到窗口 1 WPF 中的页面
- delphi - 传递给 midiInClose 的句柄无效
- excel - 多张纸的价值之间的差异
- excel - 将数据从共享点导出到 Excel
- php - Magento 2:获取类别描述
- java - 用于播放 .mid 文件的 javax.sound.midi 库不起作用
- angular - 如何在角度显示中制作表格
- node.js - 节点js条带连接缺少request_capabilities:来自创建帐户功能的['card_payments']参数
- r - R中的str_extract:提取一个不跟随某些字符的字符串