![](/img/trans.png)
[英]Meteor integration testing, rest api endpoint in velocity's mirror with jasmine
[英]rest api testing with jasmine and axios
https://blog.kuldeepkamboj.com/node-rest-api-testing-with-jasmine/我已经熟悉使用请求包进行的上述编写单元测试。
当前正在尝试使用Axios https://www.npmjs.com/package/axios编写单元测试。
运行规范时没有失败,但是我相信我的代码会以静默方式失败,并且实际上不会检查状态码。 console.log(response)也不会打印任何内容。
我该如何修复该测试用例,是否有更好的方法来调试它?
describe('api exists', () => {
it('GET /info should return 200 response', (done) => {
axios.get("https://somesite.com/info")
.then((response) => {
//console.log(response); <-- does not print out anything
expect(response.statusCode).toBe(200);
})
done();
});
您也许可以尝试将done()放入promise中。
describe('api exists', () => {
it('GET /info should return 200 response', (done) => {
axios.get("https://somesite.com/info")
.then((response) => {
console.log(response);
expect(response.statusCode).toBe(200);
done();
})
});
希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.