我用react-testing-libarary来测试我的react应用程序.而我需要找到一些原因.在文档中无法实现这一点.
有没有办法做到这一点?
我将渲染输出设置为:
const dom = render(<App />);
我正在寻找符合以下条件的产品:
const input = dom.getElemenById('firstinput');
//or
const input = dom.getById('firstinput');
我用react-testing-libarary来测试我的react应用程序.而我需要找到一些原因.在文档中无法实现这一点.
有没有办法做到这一点?
我将渲染输出设置为:
const dom = render(<App />);
我正在寻找符合以下条件的产品:
const input = dom.getElemenById('firstinput');
//or
const input = dom.getById('firstinput');
我找到了一个方法.
import App from './App';
import { render, queryByAttribute } from 'react-testing-library';
const getById = queryByAttribute.bind(null, 'id');
const dom = render(<App />);
const table = getById(dom.container, 'directory-table');
我希望这有帮助.