如何在 SuperTest 中使用 PUT 方法?我得到的只是“404 Not found”作为响应。
请求处理程序:
router.put('/', function (req, res) {
res.type('json');
FooResource(req.body, function () {
res.send("{}");
});
});
测试套件:
describe("PUT /foo/fii", function () {
it("Respond with 200", function (done) {
request(app)
.put('/')
.set('Accept', 'application/json')
.expect(200, done);
});
});
最佳答案
添加:
it("Respond with 200", function (done) {
request(app)
.put('/')
.send("{}")
.expect(200)
.end(function(err, res) {
done();
})
});
现在可以用了(?)
关于javascript - 在 Supertest 上使用 PUT 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42608696/