簡體   English   中英

ts-mockito 嘲笑的承諾永遠不會解決

[英]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年代超時,拒絕似乎工作。 我究竟做錯了什么?

這是ts-mockito庫本身的一個錯誤(問題 #191 )。
拉取請求正在進行中,所以希望它會很快得到修復。
目前,在 2.6.1 版本中,它仍然存在。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM