Version 2 added automatic cleanup, which unmounts components after tests and can be enabled or disabled using the same APIs as React Testing Library. The `waitForElement` function was renamed to `waitFor` and given a matching options object. The speaker says most of that change was the rename.
React Native Testing Library 2.0 - what's new?
An unnamed Callstack speaker explains what changed in React Native Testing Library 2.0.
Calls to `waitFor` are now wrapped in `act`, so test authors do not need to handle that themselves. The `findBy` query was added in the final v1 release. The global `debug` function was removed because debugging from the rendered component is more useful.
Version 2 removed the legacy helper and `shallow` function. The speaker says shallow rendering can complicate tests when components have state; teams can reimplement the simple helper and migrate away later. The library also removed `byName`, which had been deprecated with warnings about a year earlier.
`getByType` and `getByProps` became `UNSAFE_getByType` and `UNSAFE_getByProps` because they rely on component implementation details, though the speaker says they remain available for now. The release also fixed a long-standing `getByTestId` bug and deprecated `flushMicrotasksQueue`, recommending `findBy` or `waitFor` instead. Other work included dropping Node 8 support and improving compatibility with community testing libraries.
Takeaways
- Use `waitFor` and `findBy` for asynchronous tests instead of manually flushing microtasks.
- Automatic cleanup unmounts rendered components after tests.
- Shallow rendering can cause confusion when tested components have state.
- Treat `UNSAFE_` queries as a sign that a test depends on implementation details.
- Check migration points for removed APIs such as `byName` and the global `debug` function.
Mentioned in this talk
Search inside this talk
What was claimed 9
- feature
React Native Testing Library: Version 2 introduced automatic cleanup that unmounts components.“We introduced automatic cleanup”
YouTube Unverified1 source· Talk
- integrates with
React Native Testing Library integrates with Testing Library
“We use the same APIs as React Testing Library”
YouTube Verified2 sources· Talk
- feature
React Native Testing Library: The wait-for-element API was renamed to waitFor and given an options object.“It's now called `waitFor`, and it has an options object.”
YouTube Unverified1 source· Talk
- feature
React Native Testing Library: WaitFor calls are wrapped inside act.“we now wrap `waitFor` calls inside `act`”
YouTube Unverified1 source· Talk
- feature
React Native Testing Library: The global debug function and shallow function were removed.“We removed the global `debug` function”
YouTube Unverified1 source· Talk
- feature
React Native Testing Library: The byName query was removed after a deprecation period.“Now it's completely removed.”
YouTube Unverified1 source· Talk
- feature
React Native Testing Library: Implementation-detail queries such as getByType were renamed with an UNSAFE_ prefix and retained.“we just renamed them, and we don't have plans to remove them for now”
YouTube Unverified1 source· Talk
- feature
React Native Testing Library: FlushMicrotasksQueue was deprecated; findBy or waitFor are recommended instead.“it's better to use `findBy` or `waitFor`”
YouTube Unverified1 source· Talk
- feature
React Native Testing Library: The getByTestId query had a long-standing bug fixed.“We fixed a long-standing bug in the `getByTestId` query.”
YouTube Unverified1 source· Talk








