admin管理员组文章数量:1122832
Currently trying to write unit test for frontend. but I'm having issues with how the expected type. I keep getting expected 'Expected<HttpResponse>' on my provided mock response. I have my mock response set up like
const resp = {
body: null,
status: 200,
statusText: 'Success',
type: HttpEventType.Response,
clone: '',
headers: '',
url: '',
ok: ''
};
thanks!
Currently trying to write unit test for frontend. but I'm having issues with how the expected type. I keep getting expected 'Expected<HttpResponse>' on my provided mock response. I have my mock response set up like
const resp = {
body: null,
status: 200,
statusText: 'Success',
type: HttpEventType.Response,
clone: '',
headers: '',
url: '',
ok: ''
};
thanks!
Share Improve this question edited Nov 21, 2024 at 23:56 Naren Murali 54.6k5 gold badges40 silver badges70 bronze badges asked Nov 21, 2024 at 19:17 limiwinkslimiwinks 413 bronze badges1 Answer
Reset to default 0The test cases sometimes throw error for full typing not being present, but we cannot waste time, providing the full typing for all test cases, the solution is to use any
to override these typing errors and just test the values returned.
const resp = {
body: null,
status: 200,
statusText: 'Success',
type: HttpEventType.Response,
clone: '',
headers: '',
url: '',
ok: ''
} as any;
This as any
will bypass the typescript error.
本文标签: angularjsAngular Unit Testing How to mock HttpResponse (JasminKarma)Stack Overflow
版权声明:本文标题:angularjs - Angular Unit Testing. How to mock HttpResponse (JasminKarma) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736307779a1933429.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论