lundi 22 octobre 2018

Angular test: override to use template instead of templateUrl

I have a component which contains iframe. To prevent loading not existing URL from iframe in tests I would like to mock component's template. I thought I could do it using TestBed.overrideComponent() but it has no effect. When test runs I can see the original template is present and iframe loads non-existing url.

What I tried:

fixture = TestBed.overrideComponent(IFrameComponent, {
  remove: {
    templateUrl: './iframe.component.html'
  },
  add: {
    template: '<div></div>'
  }
}).createComponent(IFrameComponent);

How can I override component to use template instead of templateUrl?

Aucun commentaire:

Enregistrer un commentaire