1. 17
    Use the Testing Playground to Help Decide Which Query to Pick
    43s

Use the Testing Playground to Help Decide Which Query to Pick

Daniel Afonso
InstructorDaniel Afonso
Share this video with your friends

Social Share Links

Send Tweet
Published a year ago
Updated a year ago

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.