问题标签 [native-testing-library]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
reactjs - React Native:如何测试 `maxLength` 和 `keyboardType` 道具以及其他输入道具?
我有一个InputAddressZipCode
仅用于 5 位美国邮政编码的组件。我可以onChangeText
使用react-test-renderer
and进行测试@testing-library/react-native
,但测试接受任何文本,例如 string ab
。但是,此输入应仅接受以下内容:
- 5 位数 (
maxLength={5}
) - 数字键盘 (
keyboardType="numeric"
)
如何使用 React Native 测试以下上述道具?
InputAddressZipCode.tsx:
InputAddressZipCode.test.tsx: