【问题标题】:Unit test ViewChild with mat sort and set content, Jasmine and Karma单元测试 ViewChild 与 mat 排序和设置内容、Jasmine 和 Karma
【发布时间】:2019-01-10 10:15:04
【问题描述】:

我有ViewChildset content。 我想知道如何使用单元测试来测试这段代码。

这张图片是代码覆盖率

  @ViewChild(MatSort) set content(content: ElementRef) {
    this.sort = content;
    Iif (this.sort) {
      this.historyReport.sort = this.sort;
    }
  }

【问题讨论】:

    标签: angular typescript unit-testing angular6 karma-jasmine


    【解决方案1】:

    在依赖项中添加 MatSortModule,对你有帮助

          imports: [MatSortModule],
          declarations: [],
          providers: [
          ]
        }).compileComponents();```
    

    【讨论】:

      猜你喜欢
      • 2016-02-24
      • 2020-08-12
      • 1970-01-01
      • 2017-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-15
      • 1970-01-01
      相关资源
      最近更新 更多