【发布时间】:2018-08-19 20:51:57
【问题描述】:
当标签环绕输入时,我发现自己在尝试从标签访问输入时遇到了麻烦。这看起来是一个很容易解决的问题,但我玩得很开心。
<label htmlFor="termsAgreement">
<input type="checkbox" name="termsAgreement"/>
<p>Here are the terms of use</p>
</label>
我认为以下方法会起作用,但没有运气:
getByLabelText('Here are the terms of use', {selector: 'input'});
可以在这里找到一个带有几个测试的小示例 sn-p:
【问题讨论】:
标签: reactjs jestjs react-testing-library