API

  • createTestComponentFactory<T>(options: SpectatorOptions<T> | Type<T>): (componentParameters?: Partial<T>, detectChanges?: boolean) => Spectator<T>
  • createHostComponentFactory<T, H = HostComponent>(options: SpectatorOptions<T, H> | Type<T>): (template: string, detectChanges?: boolean) => SpectatorWithHost<T, H>
  • createService<S>(options: Params<S> | Type<S>): SpectatorService<S>
  • createHTTPFactory<T>(dataService: Type<T>, providers = [])
  • mockProvider<T>(type: Type<T>): Provider

Spectator Methods

  • detectChanges()
    • Runs detectChanges on the tested element/host
  • query<T>(directiveOrSelector: Type<T> | string, options: { read } = { read: undefined }): T
    • Returns the first element/component/directive that is a descendant of the element on which it is invoked that matches the specified group of selectors
  • queryLast<T>(directiveOrSelector: Type<T> | string, options: { read } = { read: undefined }): T
    • Returns the last element/component/directive that is a descendant of the element on which it is invoked that matches the specified group of selectors
  • queryAll<T>(directiveOrSelector: Type<T> | string, options: { read } = { read: undefined }): []
    • Returns a static NodeList/ComponentList/Provider representing a list of elements matching the specified group of selectors which are descendants of the element on which the method was called
  • $$(selector)
    • Free style JQuery support
  • setInput(input : Partial<Component> | keyof Component, inputValue? : any)
    • Changes the value of an @Input() of the tested component
  • output<T>( output : keyof Component) : Observable<T>
    • Returns an Observable @Output() of the tested component
  • get<T>(type: Type<T> | InjectionToken<T>): T
    • Provides a wrapper for TestBed.get()
  • click(element: string | Element | DebugElement)
    • Triggers a click event
  • dispatchMouseEvent(node: string | Element | DebugElement, type: string, x = 0, y = 0, event = createMouseEvent(type, x, y)): MouseEvent
    • Triggers a mouse event
  • dispatchKeyboardEvent(node: string | Element | DebugElement, type: string, keyCode: number, target?: Element): KeyboardEvent
    • Triggers a keyboard event
  • dispatchFakeEvent(node: string | Element | DebugElement | Window, type: string, canBubble?: boolean): Event
    • Triggers any event
  • dispatchTouchEvent(node: string | Element | DebugElement, type: string, x = 0, y = 0)
    • Triggers a touch event
  • typeInElement(value: string, element: HTMLInputElement)
    • Sets focus on the input element, sets its value and dispatches the input event, simulating the user typing.
  • patchElementFocus(element: HTMLElement)
    • Patches an elements focus and blur methods to emit events consistently and predictably

Spectator Properties

  • fixture - The tested component's fixture
  • component - The tested component's instance
  • element - The tested component's native element
  • debugElement - The tested fixture's debug element

Spectator with Host Properties

  • hostFixture - The host's fixture
  • hostComponent - The host's component instance
  • hostElement - The host's native element
  • hostDebugElement - The host's fixture debug element
  • component - The tested component's instance
  • element - The tested component's native element
  • debugElement - The tested component's debug element

Spectator with Host Methods

  • setHostInput(input : Partial<Component> | keyof Component, inputValue? : any)
    • Changes the value of an @Input() of the custom host component
  • queryHost<T>(directiveOrSelector: Type<T> | string, options: { read } = { read: undefined }): T
    • Returns the first element/component/directive that is a descendant of the element on which it is invoked that matches the specified group of selectors
  • queryHostAll<T>(directiveOrSelector: Type<T> | string, options: { read } = { read: undefined }): T[]
    • Returns a static NodeList/ComponentList/Provider representing a list of elements matching the specified group of selectors which are descendants of the element on which the method was called

results matching ""

    No results matching ""