Custom render function
Summary
RNTL exposes the render function as the primary entry point for tests. If you make complex, repeating setups for your tests, consider creating a custom render function. The idea is to encapsulate common setup steps and test wiring inside a render function suitable for your tests.
Example
Example full source code.
More info
Additional params
A custom render function might accept additional parameters to allow for setting up different start conditions for a test, e.g., the initial state for global state management.
Multiple functions
Depending on the situation, you may declare more than one custom render function. For example, you have one function for testing application flows and a second for testing individual screens.
Async setup
Since render is async, your custom render function should be marked as async and use await render(). This pattern also makes it easy to add additional async setup if needed:
