【发布时间】:2020-12-11 18:45:44
【问题描述】:
我有一个简单的方法可以构造一个随机 url,例如 (https://wqwqw.com/121212 ) 121212是随机生成的。
getCall(url) {
this.http.get(url)
}
在我的测试中我有
it('test get', async (() => {
let res;
service.getCall('a').toPromise().then(x => {
res = x
})
expect(res).toEqual(response) // res is undefined
const request = httpMock.expectOne('a') // errorr
request.flush(res)
}))
我期待随叫随到,但由于 url 是随机的,我不知道它是什么,但无论我说什么,它都说''expect 1 got none' 常量响应 = [{ 数据:'字符串'}]
我不知道我做错了什么。
【问题讨论】:
标签: angular typescript jasmine karma-jasmine