React Testing Library
{ render
} from the react-testing-lib allow us to mount/render a component in virtual memory
{ screen
} from the lib allow us to read the rendered HTML
screen
has few methods to query elements from the rendered HTML, can be used to confirm the expected elements are rendered -
getByText
, getByTestId
(uses data-testid
attribute), getByAltText
etc. methods can be used
To Test a component linked to redux, render it wrapping inside <Provider>
with its's store attribute set to mock store data
Last updated