jeudi 15 octobre 2020

Angular TestBed how to include component styles

I want to test a style that comes from component corresponding css file

@Component({
  selector: 'my-link',
  templateUrl: './my-link.component.html',
  styleUrls: ['./my-link.component.scss']
})

my-link.component.scss

span {
  display: none;
}

But the span element is visible regardless. fixture.debugElement.query(By.css('span')) gives me an object and the DebugElement styles object is also empty.

How to test it with TestBed?

P.S. please don't suggest me to test it with e2e as long as this component is too small to launch such a heavy workload, I just want to know it works.

Aucun commentaire:

Enregistrer un commentaire