快递,摩卡测试始终返回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表单数据。预先感谢!

wqf163 回答:快递,摩卡测试始终返回404

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3165886.html

大家都在问