我正在使用react-testing-library来测试我的React应用程序。由于某些原因,我需要能够通过id
而不是data-testid
找到元素。文档中没有办法实现这一点。
有没有办法实现这个功能?
我有如下渲染的输出:
const dom = render(<App />);
我正在寻找类似于以下内容的东西:
const input = dom.getElementById('firstinput');
//or
const input = dom.getById('firstinput');
document.getElementById('firstinput')
。 - James Gentes