Command Shift

Testing Forecast Summary Component πŸ”¬

React Testing Library principles

First let's focus a bit more on React Testing Library.

This library reinforces testing UI elements, which are important to the end user. This means (in a hugely simplified way) that RTL will check if a component displays or holds values that a user can perceive, either with their sight or hearing (if someone uses a screen reader). Read this chapter in the RTL docs to learn more about it.

Challenge

Having this in mind try to answer following questions:

  • Which values could you test here?
  • Which RTL queries will be suitable here?
  • Can/Should you use the same assertions as you did in <LocationDetails />?
  • How many tests might you need here?

Now you can either try to write tests on your own if you feel adventurous (RTL cheatsheet can help you with that), but we would recommend checking our walkthrough for a more detailed explanation on how to approach testing.

On this page