Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/374.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未找到存根路由回调呈现路由状态_Javascript_Mocha.js_Sinon_Chai Http - Fatal编程技术网

Javascript 未找到存根路由回调呈现路由状态

Javascript 未找到存根路由回调呈现路由状态,javascript,mocha.js,sinon,chai-http,Javascript,Mocha.js,Sinon,Chai Http,我有一条路线 app.get("/test", myControllers.controllerTest) controllerTest返回当前时间作为查询结果 我的路由测试文件 describe.("GET /test", () => { it("should return correct response", done => { sinon.stub(myControllers, "controllerTest").yields(null, {time

我有一条路线

app.get("/test", myControllers.controllerTest)
controllerTest返回当前时间作为查询结果

我的路由测试文件

  describe.("GET /test", () => {
    it("should return correct response", done => {

      sinon.stub(myControllers, "controllerTest").yields(null, {time:'fake-time'});

      app = require("../../server");

      chai
        .request(app)
        .get("/test")
        .then(res => {
          expect(res.status).to.equal(200);
          expect(myControllers.controllerTest).to.have.been.calledOnce;
          done();
        })
        .catch(err=>{
          done(err)
        });
    });
  });
测试失败,它告诉我在我截取回调后,路由返回404而不是200

请注意,使用
spy
而不是
stub
可以工作。但是在这种情况下,我需要使用
stub

我错过了什么

更新

在中断回调时,我得到错误
无法获取/route
,就像回调不存在一样。这与执行
app.get('/test')

有人知道如何截取回调吗