trait ReactTestUtils extends Object
- Annotations
- @JSType() @native() @nowarn()
- Alphabetic
- By Inheritance
- ReactTestUtils
- Object
- Any
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- final type Mounted = Component[_ <: Object, _ <: Object]
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
- final val Simulate: Simulate
- final def act(body: Function0[Any]): Thenable[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.
- final def actAsync(body: Function0[Thenable[Any]]): Thenable[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.
- Annotations
- @JSName("act")
- 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
- final def findAllInRenderedTree(tree: Mounted, test: Function1[Mounted, Boolean]): Array[Mounted]
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.
- final def findRenderedComponentWithType(tree: Mounted, c: ComponentClassUntyped): Mounted
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.
- final def findRenderedDOMComponentWithClass(tree: Mounted, className: String): Mounted
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.
- final def findRenderedDOMComponentWithTag(tree: Mounted, tagName: String): Mounted
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 hasOwnProperty(v: String): Boolean
- Definition Classes
- Object
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isComponentOfType(instance: Element, c: ComponentClassUntyped): Boolean
Returns true if instance is an instance of a React componentClass.
- final def isCompositeComponent(instance: Element): Boolean
Returns true if instance is a composite component (created with React.createClass())
- final def isCompositeComponentWithType(instance: Element, c: ComponentClassUntyped): Boolean
The combination of isComponentOfType() and isCompositeComponent().
- final def isDOMComponent(instance: Element): Boolean
Returns true if instance is a DOM component (such as a <div> or <span>).
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isPrototypeOf(v: Object): Boolean
- Definition Classes
- Object
- final def mockComponent[P <: Object, S <: Object](c: ComponentClass[P, S], mockTagName: String = js.native): ComponentClass[P, S]
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.
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.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def propertyIsEnumerable(v: String): Boolean
- Definition Classes
- Object
- final def renderIntoDocument(element: Element): |[ComponentUntyped, Null]
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.
- final def scryRenderedComponentsWithType(tree: Mounted, c: ComponentClassUntyped): Array[Mounted]
Finds all instances of components with type equal to componentClass.
- final def scryRenderedDOMComponentsWithClass(tree: Mounted, className: String): Array[Mounted]
Finds all instance of components in the rendered tree that are DOM components with the class name matching className.
- final def scryRenderedDOMComponentsWithTag(tree: Mounted, tagName: String): Array[Mounted]
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 toLocaleString(): String
- Definition Classes
- Object
- def toString(): String
- Definition Classes
- AnyRef → Any
- def valueOf(): Any
- Definition Classes
- Object
- 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])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated