选择输入以按名称进行测试。反应测试 - 上的和开玩笑
有什么方法我可以选择此formik field
< input/>
在React-Testing-library
<Field
style={inputStyles}
onChange={handleChange}
required
placeholder="Name"
name='name'
value={values.name}
className={errors.name && touched.name ? `${newUserFormStyles.errorOutline} ${newUserFormStyles.input}` : newUserFormStyles.input}
/>
我的测试
test('yayayaya', () => {
const { getByRole } = render(<AddUserForm />);
const inputName = getByRole('textbox', { name: /name/i })
const inputName = screen.getByRole('input', { name: 'name' })
console.log(inputName)
})
中都没有两个变量以上成功抓住了输入字段。
Is there any way I can select this Formik Field
<input/>
in react-testing-library
<Field
style={inputStyles}
onChange={handleChange}
required
placeholder="Name"
name='name'
value={values.name}
className={errors.name && touched.name ? `${newUserFormStyles.errorOutline} ${newUserFormStyles.input}` : newUserFormStyles.input}
/>
my Test
test('yayayaya', () => {
const { getByRole } = render(<AddUserForm />);
const inputName = getByRole('textbox', { name: /name/i })
const inputName = screen.getByRole('input', { name: 'name' })
console.log(inputName)
})
neither of the two variables above is successfully grabbing the input field.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论