A synchronous, void callback that will execute as a single, complete React commit.
Call this in your tests to create a shallow renderer.
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.
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.
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.
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.
Returns true
if instance
is a user-defined component, such as a class or a function.
Returns true
if instance
is a component whose type is of a React componentClass
.
Returns true
if instance
is a DOM component (such as a <div>
or <span>
).
Returns true
if element
is any React element.
Returns true
if element
is a React element whose type is of a React componentClass
.
Returns true
if element
is a React element whose type is of a React componentClass
.
Returns true
if element
is a React element whose type is of a React componentClass
.
Returns true
if element
is a React element whose type is of a React componentClass
.
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.
Render a React element into a detached DOM node in the document. This function requires a DOM.
Finds all instances of components with type equal to componentClass
.
Finds all DOM elements of components in the rendered tree that are
DOM components with the class name matching className
.
Finds all DOM elements of components in the rendered tree that are
DOM components with the tag name matching tagName
.
Generated using TypeDoc
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
useEffect
s before returning. This also reduces the amount of re-renders done.https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks