Cover image for Write API tests for HTTP DELETE method

Write API tests for HTTP DELETE method

automationbro profile image Automation Bro ・1 min read

The HTTP DELETE method is pretty straightforward, it deletes an existing resource and if the resource is already deleted it will most likely throw a 'not found' error.

Let's take a look at an example -

  it('DELETE /users/:id', () => {
    return request
      .set('Authorization', `Bearer ${TOKEN}`)
      .then((res) => {

This will likely return the body similar to this-

{ code: 204, meta: null, data: null }

And, upon hitting the same request again, you will see a not-found error -

{ code: 404, meta: null, data: { message: 'Resource not found' } }

Check out this video to see a detailed explanation on how to work with the HTTP DELETE method:

You can also clone the GitHub repo to access this code

To learn more about API testing, check out my free tutorial series here -


I hope this post helped you out, let me know in the comments below!

Happy testing! 😄


Subscribe to my YouTube channel
Support my work - https://www.buymeacoffee.com/automationbro
Follow @automationbro on Twitter


Editor guide