react_test_utils library

Classes

ReactShallowRenderer
ReactShallowRenderer wrapper
Simulate
Event simulation interface.

Functions

createRenderer() ReactShallowRenderer
Returns a ReactShallowRenderer instance
findAllInRenderedTree(dynamic tree, ComponentTestFunction test) List
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
findRenderedComponentWithTypeV2(dynamic tree, ReactComponentFactoryProxy componentFactory) → dynamic
Same as scryRenderedComponentsWithTypeV2 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.
findRenderedDOMComponentWithClass(dynamic tree, String className) → dynamic
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.
findRenderedDOMComponentWithTag(dynamic tree, String tag) → dynamic
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.
getComponentTypeV2(ReactComponentFactoryProxy componentFactory) → dynamic
Returns the ReactComponentFactoryProxy.type of a given componentFactory.
isCompositeComponent(dynamic instance) bool
Returns true if element is a composite component. (created with React.createClass()).
isCompositeComponentWithTypeV2(dynamic instance, ReactComponentFactoryProxy componentFactory) bool
Returns true if instance is a custom composite component created using React.createClass() that is of the ReactComponentFactoryProxy.type of the provided componentFactory.
isDOMComponent(dynamic instance) bool
Returns true if instance is a DOM component (such as a
isElement(dynamic object) bool
Returns true if object is a valid React component.
isElementOfTypeV2(dynamic element, ReactComponentFactoryProxy componentFactory) bool
Returns true if element is a ReactElement that is of the ReactComponentFactoryProxy.type of the provided componentFactory.
mockComponent(ReactClass componentClass, String mockTagName) ReactClass
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
renderIntoDocument(ReactElement? instance) → dynamic
Render a Component into a detached DOM node in the document.
scryRenderedComponentsWithTypeV2(dynamic tree, ReactComponentFactoryProxy componentFactory) List
Finds all instances within the provided tree that are of the ReactComponentFactoryProxy.type of the provided componentFactory.
scryRenderedDOMComponentsWithClass(dynamic tree, String className) List
Finds all instances of components in the rendered tree that are DOM components with the class name matching className.
scryRenderedDOMComponentsWithTag(dynamic tree, String tagName) List
Finds all instances of components in the rendered tree that are DOM components with the tag name matching tagName.

Typedefs

ComponentTestFunction = bool Function(dynamic component)