我很困惑,所以如果我使用SuperTest --它看起来似乎有自己的expect断言--那么我就不需要担心使用柴了吗?或者,当我需要柴时,Supertest知道它,并使用它作为预期机制吗?
发布于 2015-07-07 19:55:54
SuperTest扩展了超级代理的request对象以包含expect函数。它的工作方式与柴氏的expect断言不太一样,但可以用于断言http响应状态和头部,并且可以与柴氏的expect混合使用。
request(app).
get('/').
expect(200). // request.expect, is status code 200?
expect('Content-Type', /json/). // request.expect, does content-type match regex /json/?
expect(function(res){ // request.expect, does this user-provided function throw?
// user-provided function can include Chai assertions
expect(res.body).to.exist;
expect(res.body).to.have.property('status');
}).
end(done);https://stackoverflow.com/questions/31277456
复制相似问题