Find element by id in react-testing-library
I feel like none of the answers really gave a complete solution, so here it is:
const result = render(<SomeComponent />);const someElement = result.container.querySelector('#some-id');
I found a way to do this.
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');
I hope this helps.
It looks you have DOM node itself as a container. Therefore, you should be able to call .querySelector('#firstinput')
with that.