David Obodo
Letters

Follow

Letters

Follow

Testing Frontend Applications: User Story 4 - User can delete a post (Part 3E)

David Obodo's photo
David Obodo
ยทNov 23, 2022ยท

1 min read

Testing Frontend Applications: User Story 4 - User can delete a post (Part 3E)
OTHER ARTICLES IN SERIES


delete-post.png

Line 1 : Write the description of our test block

Line 2 : Render the component and set up user events

Line 4 : Since we want to delete posts, we need to be certain that posts already exist in our document, so we wait for the "Loading..." text to be removed

Line 6 : Get posts in the document. As usual, since we are testing the "accessible way" we use our getAllByRole

Line 7 : We get the first post

Line 9 : Use the within key to get the "Delete" button inside the first post

Line 11 : Click the delete button

Line 13 : Assert that an axios delete call has been made

Line 15 : Get the remaining posts

Line 16 : Assert that there are now 9 posts, since initially they were 10 and we have deleted just 1.

Next => #3F: Snapshot Tests and Conclusion
ย 
Share this