2017-03-05 83 views
0

如何用SuperTest測試PUT方法?我所得到的是「404未找到」作爲迴應。Supertest PUT方法

請求:

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); 

    }); 
}); 

你能甚至測試PUT的方法與supertest?如果可以的話,你是怎麼做到的?

回答

0

補充:(?)

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

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

    }); 

而現在它的工作原理