【发布时间】:2021-04-21 03:44:13
【问题描述】:
没有try catch块,当有断言错误时测试正常失败
describe("POST /foo", function () {
it('should create a foo', async function () {
const response = await request.post("/foo").send(data);
expect(response.status).to.eql(200); //Assertion error
}).timeout(10000);
})
//+ expected - actual -500 + 200 1 failing
但是,如果我用 try/catch 块包装它,测试就会通过
describe("POST /foo", function () {
it('should create a foo', async function () {
try {
const response = await request.post("/foo").send(data);
expect(response.status).to.eql(200); //Assertion error
} catch (err) {
}
})
})
//1 passing
【问题讨论】:
标签: node.js async-await mocha.js chai supertest