Simulate an event dispatch on a DOM node with optional `eventData` event data. **This is possibly the single most useful utility in `ReactTestUtils`.**
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.
@ -55,7 +63,9 @@ Pass a mocked component module to this method to augment it with useful methods
### isElement
```javascript
boolean isElement(ReactElement element)
boolean isElement(
ReactElement element
)
```
Returns `true` if `element` is any ReactElement.
@ -63,7 +73,10 @@ Returns `true` if `element` is any ReactElement.
### isElementOfType
```javascript
boolean isElementOfType(ReactElement element, function componentClass)
boolean isElementOfType(
ReactElement element,
function componentClass
)
```
Returns `true` if `element` is a ReactElement whose type is of a React `componentClass`.
@ -71,7 +84,9 @@ Returns `true` if `element` is a ReactElement whose type is of a React `componen
### isDOMComponent
```javascript
boolean isDOMComponent(ReactComponent instance)
boolean isDOMComponent(
ReactComponent instance
)
```
Returns `true` if `instance` is a DOM component (such as a `<div>` or `<span>`).
@ -79,7 +94,9 @@ Returns `true` if `instance` is a DOM component (such as a `<div>` or `<span>`).
Returns `true` if `instance` is a composite component (created with `React.createClass()`).
@ -87,7 +104,10 @@ Returns `true` if `instance` is a composite component (created with `React.creat
### isCompositeComponentWithType
```javascript
boolean isCompositeComponentWithType(ReactComponent instance, function componentClass)
boolean isCompositeComponentWithType(
ReactComponent instance,
function componentClass
)
```
Returns `true` if `instance` is a composite component (created with `React.createClass()`) whose type is of a React `componentClass`.
@ -95,7 +115,10 @@ Returns `true` if `instance` is a composite component (created with `React.creat
### findAllInRenderedTree
```javascript
array findAllInRenderedTree(ReactComponent tree, function test)
array findAllInRenderedTree(
ReactComponent tree,
function test
)
```
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.
@ -103,7 +126,9 @@ Traverse all components in `tree` and accumulate all components where `test(comp
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.
@ -119,7 +147,10 @@ Like `scryRenderedDOMComponentsWithClass()` but expects there to be one result,
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.
@ -135,7 +169,10 @@ Like `scryRenderedDOMComponentsWithTag()` but expects there to be one result, an
### scryRenderedComponentsWithType
```javascript
array scryRenderedComponentsWithType(ReactComponent tree, function componentClass)
array scryRenderedComponentsWithType(
ReactComponent tree,
function componentClass
)
```
Finds all instances of components with type equal to `componentClass`.
@ -143,7 +180,9 @@ Finds all instances of components with type equal to `componentClass`.
### findRenderedComponentWithType
```javascript
ReactComponent findRenderedComponentWithType(ReactComponent tree, function componentClass)
ReactComponent findRenderedComponentWithType(
ReactComponent tree, function componentClass
)
```
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.
Call this in your tests to create a shallow renderer. You can think of this as a "place" to render the component you're testing, where it can respond to events and update itself.