我尝试使用supertest-as-promised和chai的expect。测试应该是这样的:在foos端点上发布一些bars,然后调用JSON端点,其中响应的正文长度为2。
it('should fail', function(){
var agent = request(app)
agent
.post('/foos')
.send({
// some JSON
})
.then(function(){
agent.get('/bars').then(function(res){
console.log(res);
expect(res).to.have.deep.property('body.data').and.have.property('length').and.equal(3)
})
})
})console.log不会运行,并且无论我写成equal,测试都会通过。
https://stackoverflow.com/questions/38260893
复制相似问题