Querying is difficult! Even if we follow the guiding principles and always start from the queries accessible to everyone, we are bound to get stuck sometimes. To help us out, the Testing Playground was created.
In this lesson, we are going to see how to use the Testing Playground to help us know which query we should use for each element on our UI.
Instructor: [0:00] Learning about queries takes time. Often, we don't know which query to pick for each scenario. To help deal with this, we can leverage the testing playground.
[0:08] The testing playground is a tool you can use that receives your HTML and allows you to click on each item. For each item you click on, it will tell you which query should you resort to for your tests.
[0:18] Now, you don't need to go ahead and copy your entire HTML and paste it there, because the Testing Library's screen object can help you out. All you need to do is, in your tests, call screen.logTestingPlaygroundURL.
[0:30] Now, if you run your test, it will print a URL that you can click on. This URL will contain a testing playground instance with your HTML that allows you to check all the ideal queries to use in your specific case.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!