I am able to select the child component easily with Enzyme but I would like to use react-testing-library. Suppose I have a component that returns the following:
return (
<DropdownButton>
<Dropdown.Item data-testid='x' key={id} />
</DropdownButton>
)
As of now in a test I can easily select the Dropdown.Item
with const item = wrapper.find(Dropdown.Item)
but how come I cannot select via const { getByTestId } = render(<MyComponent />)
and const item = getByTestId('x')
using react-testing-library and data-testid?
Should I be using a different query?
testing-library
testing-library.com/docs/guiding-principles - johnny peter