Angular Component testing - query by Component

Discussão em 'Angular' iniciado por LppEdd, Janeiro 13, 2025.

  1. LppEdd

    LppEdd Guest

    When testing the DOM representation of a @Component, you're able to query its nested elements via its fixture

    fixture.debugElement.queryAll(By.css('.example'));


    You can also filter by @Directive

    fixture.debugElement.queryAll(By.directive(RouterLinkDirectiveStub));


    Now, let's say you have an inner @Component NzButtonComponent used like this

    <button nz-button>Example</button>


    How can I precisely query for it? There is no By.component(...).

    Continue reading...

Compartilhe esta Página