in react testing library, as per the conventions, it is better to use screen than to destructure the methods from render.
I have a component, where I need to test the text that is rendered. The top level container in this component is a div, so there is no accessible query to get the text match. How do I use screen to do a text match?
I have currently resorted to using container from the destructured props, and then doing a text match on container.
// MyComponent - simplified
const MyComponent = () => <div> some text </div>
// test
const { container } = render(<MyComponent />);
expect(container).toHaveTextContent(...)
Reference: https://kentcdodds.com/blog/common-mistakes-with-react-testing-library#not-using-screen
In the blog post it is mentioned that destructuring is mostly supported for legacy purposes, but there are no use cases which can't be solved using screen. Is this use case solvable using screen?