在Angular 13升级后,茉莉单元测试失败 - 预期的一个匹配请求“匹配方法:post,url:api/x/x search”,找到无
从12个升级到Angular 13后,一些单元测试开始失败:
错误:预期的一个标准匹配请求“匹配方法:post,url:api/x/x-search”,没有发现。
这是模拟
async function mockXSearch(error?: string) {
const req = httpMock.expectOne({ method: 'POST', url: 'api/x/x-search' });
if (error) {
req.flush({ title: errorMsg }, { status: 500, statusText: 'Internal Server Error' });
} else {
req.flush(mockX, { status: 200, statusText: 'OK' });
}
return page.whenStable();
}
,这是服务:
searchX(someData: string, foo: number, xType: XType) {
return this.http.post<X[]>(`${this.baseUrl}/x-search`, { someData, foo, xType });
}
我已经检查了模拟URL和服务URL使匹配。 有什么想法吗?
After upgrading to Angular 13 from 12, some of the Unit Tests started failing:
Error: Expected one matching request for criteria "Match method: POST, URL: api/x/x-search", found none.
This is the mock
async function mockXSearch(error?: string) {
const req = httpMock.expectOne({ method: 'POST', url: 'api/x/x-search' });
if (error) {
req.flush({ title: errorMsg }, { status: 500, statusText: 'Internal Server Error' });
} else {
req.flush(mockX, { status: 200, statusText: 'OK' });
}
return page.whenStable();
}
And this is the service:
searchX(someData: string, foo: number, xType: XType) {
return this.http.post<X[]>(`${this.baseUrl}/x-search`, { someData, foo, xType });
}
I already checked that the Mock Url and the Service Url make match.
Any idea ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论