[英]ts-mockito mocked promise never resolves
鑒於這種
beforeAll(() => {
testContainer.register(Beans.CEC_LOCATION, {
useFactory: (c) => {
const contextMock = mock<ContentfulEntryContext<ContentfulLocationFields>>();
const entryMock = mock<Entry<ContentfulLocationFields>>();
when(entryMock.fields).thenReturn({
id: '42',
name: 'Deep Mind',
});
when(contextMock.get()).thenResolve(instance(entryMock));
const location = (id: string) => {
return instance(contextMock);
};
location('42').get().then((v) => console.log(v));
return location;
},
});
});
當location.get()
被調用, then
從未做出決議,即使是在60年代超時,拒絕似乎工作。 我究竟做錯了什么?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.