【发布时间】:2019-03-30 21:52:17
【问题描述】:
我正在使用react-testing-libarary 来测试我的 React 应用程序。出于某种原因,我需要能够通过id 而不是data-testid 找到元素。文档中没有办法实现这一点。
有没有办法做到这一点?
我的渲染输出为:
const dom = render(<App />);
我正在寻找符合以下条件的东西:
const input = dom.getElemenById('firstinput');
//or
const input = dom.getById('firstinput');
【问题讨论】:
-
这对我有用:
document.getElementById('firstinput')
标签: reactjs react-testing-library