Supertest test delete method return 404 but client works

I am using supertest to test my api, the delete endpoint works fine when tested with some reassuring client like postman, but not with success.

it('should return 200', function (done) {
        request(app)
            .del('/v1/xxxx/' + id)
            .expect('Content-Type', /json/)
            .expect(200, done);
    });

      

But it passes the test when I add

it('should return 200', function (done) {
        request(app)
            .del('/v1/xxxx/' + id)
            .send({})
            .expect('Content-Type', /json/)
            .expect(200, done);
    });

      

Can someone tell me why?

+3


source to share


1 answer


It is not clear from your post what this question might be exactly. Most likely the wrong URL is '/ v1 / xxxx /'. Could it be '/ api /..../ v1 / xxx /' + id ????

In my own case, this was the problem. And I can report that supertest works exactly as expected by .del (...) or .delete (....).



Hope this helps someone else who gets into this problem.

0


source







All Articles