trait ReactTestUtils extends ReactTestUtilExtensions
- Alphabetic
- By Inheritance
- ReactTestUtils
- ReactTestUtilExtensions
- ReactTestUtilExtensions1
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- type CompType = ComponentRaw { type Raw <: japgolly.scalajs.react.facade.React.ComponentClassUntyped }
- type Mounted = MountedRaw
- type MountedOutput = MountedWithRoot[Id, util.DefaultEffects.Async, Object, Object, RawMounted[Object, Object], Object, Object]
- type Unmounted[M] = component.Generic.Unmounted[_, M]
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def act[A](body: => A): A
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 assertionsThis helps make your tests run closer to what real users would experience when using your application.
- def actAsync[F[_], A](body: F[A])(implicit F: Async[F]): F[A]
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.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- 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.
- 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.
- 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.
- 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.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def modifyProps[P, U <: component.Generic.Unmounted[P, M], M <: MountedImpure[P, _]](c: internal.CoreGeneral.GenericComponent[P, Props, U], m: M)(f: (P) => P): M
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def newBodyElement(): Element
- def newDocumentElement(): Element
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- implicit final def reactTestExtMountedImpure[A[_], P, S](m: MountedSimple[Id, A, P, S]): ReactTestExt_MountedSimple[Id, A, P, S]
- Definition Classes
- ReactTestUtilExtensions
- implicit final def reactTestExtMountedSimple[F[_], A[_], P, S](m: MountedSimple[F, A, P, S]): ReactTestExt_MountedSimple[F, A, P, S]
- Definition Classes
- ReactTestUtilExtensions1
- def removeNewBodyElement(e: Element): Unit
- def removeNewDocumentElement(e: Element): Unit
- def removeReactInternals(html: String): String
Turn
<div data-reactroot="">hello</div>into<div>hello</div> - def renderIntoBody[M](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.
- def renderIntoDocument(e: VdomElement): MountedOutput
- 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.
- def replaceProps[P, U <: component.Generic.Unmounted[P, M], M <: MountedImpure[P, _]](c: internal.CoreGeneral.GenericComponent[P, Props, U], m: M)(p: P): M
- def scryRenderedComponentsWithType(tree: Mounted, c: CompType): Vector[MountedOutput]
Finds all instances of components with type equal to componentClass.
- 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.
- 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.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def unmountRawComponent(c: |[ComponentUntyped, Null]): Unit
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def withNewBodyElement[A](use: (Element) => A): A
- def withNewBodyElementAsync[F[_], A](use: (Element) => F[A])(implicit F: Async[F]): F[A]
- def withNewBodyElementFuture[A](use: (Element) => Future[A])(implicit ec: ExecutionContext): Future[A]
- def withNewDocumentElement[A](use: (Element) => A): A
- def withNewDocumentElementAsync[F[_], A](use: (Element) => F[A])(implicit F: Async[F]): F[A]
- def withNewDocumentElementFuture[A](use: (Element) => Future[A])(implicit ec: ExecutionContext): Future[A]
- def withRendered[M](u: Unmounted[M], intoBody: Boolean): WithRenderedDsl[M, Element]
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().
- def withRenderedAsync[M](u: Unmounted[M], intoBody: Boolean): WithRenderedDslF[util.DefaultEffects.Async, M, Element]
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().
- 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().
- def withRenderedIntoBody[M](u: Unmounted[M]): WithRenderedDsl[M, Element]
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.
- def withRenderedIntoBodyAsync[M](u: Unmounted[M]): WithRenderedDslF[util.DefaultEffects.Async, M, Element]
Renders a component into the document body via ReactDOM.render(), and asynchronously waits for the Async to complete before unmounting.
- 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.
- def withRenderedIntoDocument[M](u: Unmounted[M]): WithRenderedDsl[M, Element]
Renders a component into detached DOM via ReactTestUtils.renderIntoDocument(), then unmounts and cleans up after use.
- def withRenderedIntoDocumentAsync[M](u: Unmounted[M]): WithRenderedDslF[util.DefaultEffects.Async, M, Element]
Renders a component into the document body via ReactDOM.render(), and asynchronously waits for the Async to complete before unmounting.
- 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
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated