javascript - 快递,摩卡测试总是返回404
问题描述
我的快递 POST 路线是:
app.post("/addPost", function(req, res) {
let newComment = { post: req.body.createP, comment: req.body.createC };
myDB.push(newComment);
res.render("index.ejs", { posts: myDB });
});
还有我的摩卡测试
describe("POST /", function() {
it("it ", function(done) {
supertest(myApp.app)
.post("/")
.expect(200)
.end(function(err, res) {
if (err) return done(err);
done();
});
});
});
手动,POST 路由工作正常,但 mocha 测试总是返回 404 而不是 200。此外,GET 路由的 mocha 测试确实有效。有什么想法是什么原因造成的?
另外,如何测试通过 POST 请求发送的 html 表单数据。提前致谢!