From the course: Learning End-to-End Testing with Jest

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Test the Update endpoint

Test the Update endpoint

- [Instructor] Now is the time to test the update endpoint. I will group tests for the update endpoint in a describe method and give it a description of 'PATCH/recipes/:id'. For the positive test, the description is 'update the recipe record in the db'. Define the input which is the update you want to make. So name is 'chicken nuggets'. Call the update endpoint with the ID of the recipe you want to update. Send the input and set the authorization. We expect a response with statusCode of 200 and response body of an object containing success : true and data of any object. Save and run tests. 14 tests passed. Our coverage is 88.41% The updates will have a good number of negative tests, just like the create endpoint. The first is to test for a user who wants to update a recipe with an invalid difficulty value. The test description is 'it should not update recipe in the db, invalid difficulty value'.…

Contents