Returns a `RenderResult` object with following properties:
### `getByTestId: (testID: string)`
A method returning a `ReactTestInstance` with matching `testID` prop. Throws when no matches.
_Note: most methods like this one return a [`ReactTestInstance`](https://reactjs.org/docs/test-renderer.html#testinstance) with following properties that you may be interested in:_
```jsx
typeReactTestInstance={
type:string|Function,
props:{[propName:string]:any},
parent:null|ReactTestInstance,
children:Array<ReactTestInstance|string>,
};
```
### `getByText: (text: string | RegExp)`
A method returning a `ReactTestInstance` with matching text – may be a string or regular expression. Throws when no matches.
This method will join `<Text>` siblings to find matches, similarly to [how React Native handles these components](https://facebook.github.io/react-native/docs/text#containers). This will allow for querying for strings that will be visually rendered together, but may be semantically separate React components.
A method returning a `ReactTestInstance` for a `TextInput` with a matching placeholder – may be a string or regular expression. Throws when no matches.
A method returning a `ReactTestInstance` with matching a React component type. Throws when no matches.
> This method has been **deprecated** because using it results in fragile tests that may break between minor React Native versions. It will be removed in next major release (v2.0). Use [`getByType`](#getbytype-type-reactcomponenttype) instead.
A method returning an array of `ReactTestInstance`s with matching a React component type.
> This method has been **deprecated** because using it results in fragile tests that may break between minor React Native versions. It will be removed in next major release (v2.0). Use [`getAllByType`](#getallbytype-type-reactcomponenttype) instead.
Re-render the in-memory tree with a new root element. This simulates a React update at the root. If the new element has the same type and key as the previous element, the tree will be updated; otherwise, it will re-mount a new tree. This is useful when testing for `componentDidUpdate` behavior, by passing updated props to the component.
Unmount the in-memory tree, triggering the appropriate lifecycle events
When using React context providers, like Redux Provider, you'll likely want to wrap rendered component with them. In such cases it's convenient to create your custom `render` method. [Follow this great guide on how to set this up](https://github.com/kentcdodds/react-testing-library#custom-render).
### `debug: (message?: string) => void`
Prints deeply rendered component passed to `render` with optional message on top. Uses [debug.deep](#debug) under the hood, but it's easier to use.
```jsx
const{debug}=render(<Component/>);
debug('optional message');
```
logs optional message and colored JSX:
```jsx
optionalmessage
<TouchableOpacity
activeOpacity={0.2}
onPress={[Functionboundfn]}
>
<Text>Pressme</Text>
</TouchableOpacity>
```
### `debug.shallow: (message?: string) => void`
Prints shallowly rendered component passed to `render` with optional message on top. Uses [debug.shallow](#debug) under the hood, but it's easier to use.
### `toJSON: () => ?ReactTestRendererJSON`
Get the rendered component JSON representation, e.g. for snapshot testing.
Invokes a given event handler (whether native or custom) on the element, bubbling to the root of the rendered tree. The three most common events (`press`, `changeText`, and `scroll`) have been aliased for convenience.
Invokes named event handler on the element or parent element in the tree. For better readability, `fireEvent` strips the `on` part of the handler prop name, so it will fire `onMyCustomEvent` when `myCustomEvent` is passed as `eventName`.
Waits for non-deterministic periods of time until your element appears or times out. `waitForExpect` periodically calls `expectation` every `interval` milliseconds to determine whether the element appeared or not.
If you're using Jest's [Timer Mocks](https://jestjs.io/docs/en/timer-mocks#docsNav), remember not to use `async/await` syntax as it will stall your tests.
Each of the get APIs listed in the render section above have a complimentary query API. The get APIs will throw errors if a proper node cannot be found. This is normally the desired effect. However, if you want to make an assertion that an element is not present in the hierarchy, then you can use the query API instead:
```jsx
import{render}from'react-native-testing-library';
const{queryByText}=render(<Form/>);
constsubmitButton=queryByText('submit');
expect(submitButton).toBeNull();// it doesn't exist
```
## `queryAll` APIs
Each of the query APIs have a corresponding queryAll version that always returns an Array of matching nodes. getAll is the same but throws when the array has a length of 0.
```jsx
import{render}from'react-native-testing-library';
const{queryAllByText}=render(<Forms/>);
constsubmitButtons=queryAllByText('submit');
expect(submitButtons).toHaveLength(3);// expect 3 elements
Useful function to help testing components that use hooks API. By default any `render`, `update`, and `fireEvent` calls are wrapped by this function, so there is no need to wrap it manually. This method is re-exported from [`react-test-renderer`](https://github.com/facebook/react/blob/master/packages/react-test-renderer/src/ReactTestRenderer.js#L567]).