Short answer: no.
React Native Testing Library does not provide an entire React Native runtime since that would require running on a physical device or iOS simulator/Android emulator to provision the underlying OS and platform APIs.
Instead of using React Native renderer, it simulates only the JavaScript part of its runtime using React Test Renderer while providing queries and event APIs (User Event, Fire Event) that mimicking certain behaviors from the actual runtime.
You can learn more about our testing environment here.
This approach has specific benefits and shortfalls. On the positive side:
On the negative side:
The User Event interactions solve some of the simulation issues, as they offer more realistic event handling than the basic Fire Event API.
screen
queries?There is no need to migrate existing test code to use screen
-bases queries. You can still use
queries and other functions returned by render
. The screen
object captures the latest render
result.
For new code, you are encouraged to use screen
as there are some good reasons for that, which are described in this article by Kent C. Dodds.
We encourage you to migrate existing tests to use the User Event interactions, which offer more realistic event handling than the basic Fire Event API. Hence, it will provide more confidence in the quality of your code.