Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "node_modules/@types/react-dom/test-utils/index.d"

Index

Type aliases

EventSimulator

EventSimulator: function

Type declaration

Functions

act

  • act(callback: function): DebugPromiseLike
  • act(callback: function): Promise<undefined>
  • Wrap any code rendering and triggering updates to your components into act() calls.

    Ensures that the behavior in your tests matches what happens in the browser more closely by executing pending useEffects before returning. This also reduces the amount of re-renders done.

    see

    https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks

    Parameters

    • callback: function

      A synchronous, void callback that will execute as a single, complete React commit.

        • (): void | undefined
        • Returns void | undefined

    Returns DebugPromiseLike

  • Parameters

    • callback: function
        • (): Promise<void | undefined>
        • Returns Promise<void | undefined>

    Returns Promise<undefined>

createRenderer

  • Call this in your tests to create a shallow renderer.

    Returns ShallowRenderer

findAllInRenderedTree

  • Traverse all components in tree and accumulate all components where test(component) is true. This is not that useful on its own, but it's used as a primitive for other test utils.

    Parameters

    Returns ReactInstance[]

findRenderedComponentWithType

  • findRenderedComponentWithType<T, C>(root: Component<any>, type: ClassType<any, T, C>): T
  • Same as scryRenderedComponentsWithType() but expects there to be one result and returns that one result, or throws exception if there is any other number of matches besides one.

    Type parameters

    Parameters

    Returns T

findRenderedDOMComponentWithClass

  • findRenderedDOMComponentWithClass(root: Component<any>, className: string): Element
  • Like scryRenderedDOMComponentsWithClass() but expects there to be one result, and returns that one result, or throws exception if there is any other number of matches besides one.

    Parameters

    Returns Element

findRenderedDOMComponentWithTag

  • findRenderedDOMComponentWithTag(root: Component<any>, tagName: string): Element
  • Like scryRenderedDOMComponentsWithTag() but expects there to be one result, and returns that one result, or throws exception if there is any other number of matches besides one.

    Parameters

    Returns Element

isCompositeComponent

  • isCompositeComponent(instance: ReactInstance): instance is Component<any>
  • Returns true if instance is a user-defined component, such as a class or a function.

    Parameters

    Returns instance is Component<any>

isCompositeComponentWithType

  • Returns true if instance is a component whose type is of a React componentClass.

    Type parameters

    Parameters

    Returns boolean

isDOMComponent

  • Returns true if instance is a DOM component (such as a <div> or <span>).

    Parameters

    Returns instance is Element

isElement

  • isElement(element: any): boolean
  • Returns true if element is any React element.

    Parameters

    • element: any

    Returns boolean

isElementOfType

  • isElementOfType<T>(element: ReactElement, type: string): element is ReactHTMLElement<T>
  • isElementOfType<P, T>(element: ReactElement, type: string): element is DOMElement<P, T>
  • isElementOfType<P>(element: ReactElement, type: SFC<P>): element is SFCElement<P>
  • isElementOfType<P, T, C>(element: ReactElement, type: ClassType<P, T, C>): element is CElement<P, T>
  • Returns true if element is a React element whose type is of a React componentClass.

    Type parameters

    • T: HTMLElement

    Parameters

    Returns element is ReactHTMLElement<T>

  • Returns true if element is a React element whose type is of a React componentClass.

    Type parameters

    Parameters

    Returns element is DOMElement<P, T>

  • Returns true if element is a React element whose type is of a React componentClass.

    Type parameters

    • P

    Parameters

    Returns element is SFCElement<P>

  • Returns true if element is a React element whose type is of a React componentClass.

    Type parameters

    Parameters

    Returns element is CElement<P, T>

mockComponent

  • Pass a mocked component module to this method to augment it with useful methods that allow it to be used as a dummy React component. Instead of rendering as usual, the component will become a simple <div> (or other tag if mockTagName is provided) containing any provided children.

    Parameters

    Returns "node_modules/@types/react-dom/test-utils/index.d"

renderIntoDocument

  • Render a React element into a detached DOM node in the document. This function requires a DOM.

    Type parameters

    • T: Element

    Parameters

    Returns T

  • Parameters

    Returns void

  • Type parameters

    Parameters

    Returns T

  • Type parameters

    • P

    Parameters

    Returns Component<P> | Element | void

scryRenderedComponentsWithType

  • scryRenderedComponentsWithType<T, C>(root: Component<any>, type: ClassType<any, T, C>): T[]
  • Finds all instances of components with type equal to componentClass.

    Type parameters

    Parameters

    Returns T[]

scryRenderedDOMComponentsWithClass

  • scryRenderedDOMComponentsWithClass(root: Component<any>, className: string): Element[]
  • Finds all DOM elements of components in the rendered tree that are DOM components with the class name matching className.

    Parameters

    Returns Element[]

scryRenderedDOMComponentsWithTag

  • scryRenderedDOMComponentsWithTag(root: Component<any>, tagName: string): Element[]
  • Finds all DOM elements of components in the rendered tree that are DOM components with the tag name matching tagName.

    Parameters

    Returns Element[]

Generated using TypeDoc