debug.md

December 8, 2023 · View on GitHub

🏠   →   Documentation   →   Built-In Functionality   →   debug

Other Predicates:   attributescallLifeCycleHookcallclicked ・ debug ・ detectChangesemitproviderstatewaitFakeAsync


This predicate prints out the test-DOM at the moment it gets called. Takes an optional configuration-parameter further adjusting its behavior.

Signature

debug(opts?: DebugOptions);

Interface DebugOptions

interface DebugOptions {
  stateOf?: TargetRef<HTMLElement, any>;
}

When passing the stateOf option, the predicate will additionally print out the component state of the target(s) passed.

Examples

class the {
  static DropDownItem() {
    return get(DropDownItemComponent);
  }
}

it('should print out the DOM after setting DropDownItem state', () => {
  When(the.DropDownItem)
    .has(state({ value: 'Item 1' }))
    .and(debug()) // prints out DOM at this stage of the test
    .expect(the.DropDown)
    .to(haveState({ value: 'Item 1' }));
});

it('should additionally print out the drop-down-items component state', () => {
  When(the.DropDownItem)
    .has(state({ value: 'Item 1' }))
    .and(debug({ stateOf: the.DropDownItem })) // prints out DOM and component-state of DropDownItem
    .expect(the.DropDown)
    .to(haveState({ value: 'Item 1' }));
});