[ Web Proxy ]
URL:
Viewing: https://angular.dev/api/core/testing/DirectiveFixture [Back]  [Original]

DirectiveFixture Angular Skip to main content
menu
close
more_horiz
menuAPI
@angular/core/testing

DirectiveFixture

Class
stable

Fixture for debugging and testing a directive.

On this page

    arrow_upward_alt Back to the top

    API

        
          class DirectiveFixture<T> extends AbstractFixture<Element> {  constructor(hostRef: ComponentRef<unknown>, directiveInstance: T);  readonly directiveInstance: T;  onDestroy(callback: () => void): void;  override debugElement: DebugElement;  override nativeElement: E;  override elementRef: ElementRef<E>;  readonly override changeDetectorRef: ChangeDetectorRef;  override detectChanges(checkNoChanges?: boolean): void;  override checkNoChanges(): void;
    override autoDetectChanges(autoDetect: boolean): void; override autoDetectChanges(): void;
    override isStable(): boolean; override whenStable(): Promise<any>; override whenRenderingDone(): Promise<any>; override destroy(): void;}

    constructor

    DirectiveFixture<T>
    @paramhostRefComponentRef<unknown>
    @paramdirectiveInstanceT
    @returnsDirectiveFixture<T>

    directiveInstance

    T

    The instance of the directive class.

    onDestroy

    void

    Registers a callback that will be invoked when the fixture is destroyed.

    @paramcallback() => void
    @returnsvoid

    debugElement

    DebugElement

    The DebugElement associated with the root element of this component.

    nativeElement

    E

    The native element at the root of the component.

    elementRef

    ElementRef<E>

    The ElementRef for the element at the root of the component.

    changeDetectorRef

    ChangeDetectorRef

    detectChanges

    void

    Trigger a change detection cycle for the component.

    @paramcheckNoChangesboolean
    @returnsvoid

    checkNoChanges

    void

    Do a change detection run to make sure there were no changes.

    @returnsvoid

    autoDetectChanges

    2 overloads

    Set whether the fixture should autodetect changes.

    Also runs detectChanges once so that any existing change is detected.

    @deprecated

    For autoDetect: true, use autoDetectChanges(). We have not seen a use-case for autoDetect: false but changeDetectorRef.detach() is a close equivalent.

    @paramautoDetectboolean

    Whether to autodetect changes. By default, true.

    @returnsvoid

    Enables automatically synchronizing the view, as it would in an application.

    Also runs detectChanges once so that any existing change is detected.

    @returnsvoid

    isStable

    boolean

    Return whether the fixture is currently stable or has async tasks that have not been completed yet.

    @returnsboolean

    whenStable

    Promise<any>

    Get a promise that resolves when the fixture is stable.

    This can be used to resume testing after events have triggered asynchronous activity or asynchronous change detection.

    @returnsPromise<any>

    whenRenderingDone

    Promise<any>

    Get a promise that resolves when the ui state is stable following animations.

    @returnsPromise<any>

    destroy

    void

    Trigger component destruction.

    @returnsvoid
    Jump to details

    Web Proxy Viewer  |  New URL  |  Original Page