React 13: Testing: RTL
Docs
Common Imports
import { render, screen, cleanup , waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import '@testing-library/jest-dom';
Problem Statement
Best Practice Reminder
RTL : Install
RTL : Watch Mode
RTL : Watch Mode
RTL : render() and screen
render() and screenRTL : Example
RTL : Example
RTL : it() Example Skeleton
it() Example SkeletonRTL : getByRole() Example Skeleton
getByRole() Example SkeletonRTL : getByText() w Regex
getByText() w RegexRTL : getByX vs queryByX methods
getByX vs queryByX methodsRTL : queryByX methods
queryByX methodsRTL : queryByX methods
queryByX methodsRTL : getByX VS findByX methods
getByX VS findByX methodsRTL : getByX VS findByX vs queryByX
getByX VS findByX vs queryByXRTL : findByX methods
findByX methodsRTL : findByX + Await
findByX + AwaitRTL : Mimick User Interactions
Problem Statement
Solution
RTL : userEvent library/object
RTL : userEvent.interaction() vs user.interaction()
userEvent.interaction() vs user.interaction()RTL : waitFor() method
waitFor() methodProblem Statement
RTL : waitFor() Example
waitFor() ExampleRTL : waitFor() deets
waitFor() deetsRTL : Testing for Accessibility
RTL : Testing for Accessibility
Last updated