samedi 3 octobre 2020

Testing react component contents

I'm new to React and I'm having some trouble testing a component. I have a list of cards which represents some comments. Each card contains the username, the date posted and the body of the comment. I'm using the fake response in order to create two comments and I want to check the values of each cards, but I want to make sure that the values that I gave to the first card correspond to the first card and same for the second one. How should I approach this? Until now I used getAllByRole('listitem') and I get an array containing an object of nodes for each list item. The problem is that I don't know how to extract the values of the username, of the date and of the body so I can verify them, or how to check if the values of the username, date and body that I gave are in that object.

Aucun commentaire:

Enregistrer un commentaire