【问题标题】:how to mock global object / this.VARIABLE. in jest如何模拟全局对象/this.VARIABLE。开玩笑
【发布时间】:2022-12-24 12:29:40
【问题描述】:
export class Main {
 protected globalExpectArr: any[];
}

我想在我的开玩笑单元测试中模拟 globalExpectArr

【问题讨论】:

    标签: typescript unit-testing jestjs


    【解决方案1】:

    我认为您可以让 testClass 扩展主类,然后简单地模拟它以返回您想要将其设置为的任何内容。

    【讨论】:

      猜你喜欢
      • 2020-08-20
      • 2020-07-21
      • 2018-12-30
      • 2021-07-03
      • 2018-10-23
      • 2020-10-20
      • 1970-01-01
      • 1970-01-01
      • 2020-11-18
      相关资源
      最近更新 更多