Packages

o

japgolly.scalajs.react.test

ReactTestUtils

object ReactTestUtils

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ReactTestUtils
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. type CompType = ComponentRaw { type Raw <: japgolly.scalajs.react.raw.React.ComponentClassUntyped }
  2. type Mounted = MountedRaw
  3. type MountedOutput = component.Js.Mounted[_ <: Object, _ <: Object]
  4. type Unmounted[M] = component.Generic.Unmounted[_, M]

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def act(body: => Any): Unit

    When writing UI tests, tasks like rendering, user events, or data fetching can be considered as "units" of interaction with a user interface.

    When writing UI tests, tasks like rendering, user events, or data fetching can be considered as "units" of interaction with a user interface. React provides a helper called act() that makes sure all updates related to these "units" have been processed and applied to the DOM before you make any assertions:

    act {
      // render components
    }
    // make assertions

    This helps make your tests run closer to what real users would experience when using your application.

  5. def actAsync[A](body: AsyncCallback[A]): AsyncCallback[Unit]

    When writing UI tests, tasks like rendering, user events, or data fetching can be considered as "units" of interaction with a user interface.

    When writing UI tests, tasks like rendering, user events, or data fetching can be considered as "units" of interaction with a user interface. React provides a helper called act() that makes sure all updates related to these "units" have been processed and applied to the DOM before you make any assertions:

    await act(async () => {
      // render components
    });
    // make assertions

    This helps make your tests run closer to what real users would experience when using your application.

  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  10. def findAllInRenderedTree(tree: Mounted, test: (MountedOutput) => Boolean): Vector[MountedOutput]

    Traverse all components in tree and accumulate all components where test(component) is true.

    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.

  11. def findRenderedComponentWithType(tree: Mounted, c: CompType): MountedOutput

    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.

  12. def findRenderedDOMComponentWithClass(tree: Mounted, className: String): MountedOutput

    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.

  13. def findRenderedDOMComponentWithTag(tree: Mounted, tagName: String): MountedOutput

    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.

  14. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  15. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  16. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  17. def modifyProps[P, U <: component.Generic.Unmounted[P, M], M <: MountedImpure[P, _]](c: GenericComponent[P, Props, U], m: M)(f: (P) => P): M
  18. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  19. def newBodyElement(): Element
  20. def newDocumentElement(): Element
  21. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  22. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  23. def raw: raw.ReactTestUtils
    Annotations
    @inline()
  24. def removeNewBodyElement(e: Element): Unit
  25. def removeNewDocumentElement(e: Element): Unit
  26. def removeReactInternals(html: String): String

    Turn <div data-reactroot="">hello&lt/div> into <div>hello&lt/div>

  27. def renderIntoBody[M, A](u: Unmounted[M]): M

    Renders a component into the document body via ReactDOM.render().

    Renders a component into the document body via ReactDOM.render().

    Unlike ReactTestUtils.renderIntoDocument(), this allows DOM focus to work.

  28. def renderIntoDocument(e: VdomElement): MountedOutput
  29. def renderIntoDocument[M](unmounted: Unmounted[M]): M

    Render a component into a detached DOM node in the document.

    Render a component into a detached DOM node in the document. This function requires a DOM.

  30. def replaceProps[P, U <: component.Generic.Unmounted[P, M], M <: MountedImpure[P, _]](c: GenericComponent[P, Props, U], m: M)(p: P): M
  31. def scryRenderedComponentsWithType(tree: Mounted, c: CompType): Vector[MountedOutput]

    Finds all instances of components with type equal to componentClass.

  32. def scryRenderedDOMComponentsWithClass(tree: Mounted, className: String): Vector[MountedOutput]

    Finds all instance of components in the rendered tree that are DOM components with the class name matching className.

  33. def scryRenderedDOMComponentsWithTag(tree: Mounted, tagName: String): Vector[MountedOutput]

    Finds all instance of components in the rendered tree that are DOM components with the tag name matching tagName.

  34. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  35. def toString(): String
    Definition Classes
    AnyRef → Any
  36. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  37. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  38. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  39. def withNewBodyElement[A](use: (Element) => A): A
  40. def withNewBodyElementAsyncCallback[A](use: (Element) => AsyncCallback[A]): AsyncCallback[A]
  41. def withNewBodyElementFuture[A](use: (Element) => Future[A])(implicit ec: ExecutionContext): Future[A]
  42. def withNewDocumentElement[A](use: (Element) => A): A
  43. def withNewDocumentElementAsyncCallback[A](use: (Element) => AsyncCallback[A]): AsyncCallback[A]
  44. def withNewDocumentElementFuture[A](use: (Element) => Future[A])(implicit ec: ExecutionContext): Future[A]
  45. def withRendered[M, A](u: Unmounted[M], intoBody: Boolean)(f: (M) => A): A

    Renders a component then unmounts and cleans up after use.

    Renders a component then unmounts and cleans up after use.

    intoBody

    Whether to use renderIntoBody() or ReactTestUtils.renderIntoDocument().

  46. def withRenderedAsyncCallback[M, A](u: Unmounted[M], intoBody: Boolean)(f: (M) => AsyncCallback[A]): AsyncCallback[A]

    Renders a component then unmounts and cleans up after use.

    Renders a component then unmounts and cleans up after use.

    intoBody

    Whether to use renderIntoBodyAsyncCallback() or renderIntoDocumentAsyncCallback().

  47. def withRenderedFuture[M, A](u: Unmounted[M], intoBody: Boolean)(f: (M) => Future[A])(implicit ec: ExecutionContext): Future[A]

    Renders a component then unmounts and cleans up after use.

    Renders a component then unmounts and cleans up after use.

    intoBody

    Whether to use renderIntoBodyFuture() or renderIntoDocumentFuture().

  48. def withRenderedIntoBody[M, A](u: Unmounted[M])(f: (M) => A): A

    Renders a component into the document body via ReactDOM.render(), then unmounts and cleans up after use.

    Renders a component into the document body via ReactDOM.render(), then unmounts and cleans up after use.

    Unlike ReactTestUtils.renderIntoDocument(), this allows DOM focus to work.

  49. def withRenderedIntoBodyAsyncCallback[M, A](u: Unmounted[M])(f: (M) => AsyncCallback[A]): AsyncCallback[A]

    Renders a component into the document body via ReactDOM.render(), and asynchronously waits for the AsyncCallback to complete before unmounting.

  50. def withRenderedIntoBodyFuture[M, A](u: Unmounted[M])(f: (M) => Future[A])(implicit ec: ExecutionContext): Future[A]

    Renders a component into the document body via ReactDOM.render(), and asynchronously waits for the Future to complete before unmounting.

  51. def withRenderedIntoDocument[M, A](u: Unmounted[M])(f: (M) => A): A

    Renders a component into detached DOM via ReactTestUtils.renderIntoDocument(), then unmounts and cleans up after use.

  52. def withRenderedIntoDocumentAsyncCallback[M, A](u: Unmounted[M])(f: (M) => AsyncCallback[A]): AsyncCallback[A]

    Renders a component into the document body via ReactDOM.render(), and asynchronously waits for the AsyncCallback to complete before unmounting.

  53. def withRenderedIntoDocumentFuture[M, A](u: Unmounted[M])(f: (M) => Future[A])(implicit ec: ExecutionContext): Future[A]

    Renders a component into detached DOM via ReactTestUtils.renderIntoDocument(), and asynchronously waits for the Future to complete before unmounting.

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated
  2. def withNewBodyElementAsync[A](use: (Element) => Future[A])(implicit ec: ExecutionContext): Future[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 1.5.0) Use withNewBodyElementFuture

  3. def withRenderedAsync[M, A](u: Unmounted[M], intoBody: Boolean)(f: (M) => Future[A])(implicit ec: ExecutionContext): Future[A]

    Renders a component then unmounts and cleans up after use.

    Renders a component then unmounts and cleans up after use.

    intoBody

    Whether to use renderIntoBodyAsync() or renderIntoDocumentAsync().

    Annotations
    @deprecated
    Deprecated

    (Since version 1.5.0) Use withRenderedFuture

  4. def withRenderedIntoBodyAsync[M, A](u: Unmounted[M])(f: (M) => Future[A])(implicit ec: ExecutionContext): Future[A]

    Renders a component into the document body via ReactDOM.render(), and asynchronously waits for the Future to complete before unmounting.

    Renders a component into the document body via ReactDOM.render(), and asynchronously waits for the Future to complete before unmounting.

    Annotations
    @deprecated
    Deprecated

    (Since version 1.5.0) Use withRenderedIntoBodyFuture

  5. def withRenderedIntoDocumentAsync[M, A](u: Unmounted[M])(f: (M) => Future[A])(implicit ec: ExecutionContext): Future[A]

    Renders a component into detached DOM via ReactTestUtils.renderIntoDocument(), and asynchronously waits for the Future to complete before unmounting.

    Renders a component into detached DOM via ReactTestUtils.renderIntoDocument(), and asynchronously waits for the Future to complete before unmounting.

    Annotations
    @deprecated
    Deprecated

    (Since version 1.5.0) Use withRenderedIntoDocumentFuture

Inherited from AnyRef

Inherited from Any

Ungrouped