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 Delete endpoint

Test the Delete endpoint

- It's time to write some tests for the deletes end-point. Let's get right into it. For delete end-point, let's group each test in a described method with description: delete forward slash recipes forward slash ID. The positive tests description is: delete the specified recipe. (typing on keyboard) Call the end-point with the ID of the recipe you want to delete from the database. Because this is still a rights to database and sensitive, we have to set the authorization. You don't want unauthorized users making changes to your database. (typing on keyboard) We expect the response status code to be 200, (typing on keyboard) and response body to be an object containing success through and message 'recipe successfully deleted.' Server run test. Good. 20 tests pass. Our coverage is now 95.65%. Let's consider an unauthorized user. Test description is 'failed to delete the specified recipe, invalid token'. (typing on…

Contents