【问题标题】:angular 5 test static method of componentangular 5 测试组件的静态方法
【发布时间】:2018-07-22 16:07:23
【问题描述】:

我正在测试的 Component 类上有一个静态方法,我的问题是如何在我的规范测试文件中访问该方法?

到目前为止,我可以通过以下方式访问组件实例:

  let fixture = TestBed.createComponent(MyComponent);
  let comp = fixture.componentInstance;

【问题讨论】:

标签: angular jasmine angular-test


【解决方案1】:

静态方法不绑定到类的实例。所以这样的事情应该可以工作:MyComponent.nameOfStaticMethod(params)

【讨论】:

  • 甜蜜!祝你好运!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-01-15
  • 1970-01-01
  • 2015-05-26
  • 2019-05-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多