Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using PUT method on Supertest

How do I use a PUT method with SuperTest? All I get is "404 Not found" as response.

The request handler:

router.put('/', function (req, res) {
    res.type('json');

    FooResource(req.body, function () {
        res.send("{}");
    });
});

The test suite:

describe("PUT /foo/fii", function () {

    it("Respond with 200", function (done) {

        request(app)
            .put('/')
            .set('Accept', 'application/json')
            .expect(200, done);

    });
});
like image 458
Jesper Avatar asked Jul 27 '26 03:07

Jesper


1 Answers

Added:

    it("Respond with 200", function (done) {

        request(app)
            .put('/')
            .send("{}")
            .expect(200)
            .end(function(err, res) {
                done();
            })

    });

And now it works(?)

like image 172
Jesper Avatar answered Jul 28 '26 16:07

Jesper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!