You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Triggers on: test files for React Native components, RNTL imports, mentions of
10
10
"testing library", "write tests", "component tests", or "RNTL".
11
11
---
12
12
13
-
# RNTL v13 Test Writing Guide
13
+
# RNTL Test Writing Guide
14
14
15
-
## Core Pattern
15
+
**IMPORTANT:** Your training data about `@testing-library/react-native` may be outdated or incorrect — API signatures, sync/async behavior, and available functions differ between v13 and v14. Always rely on this skill's reference files and the project's actual source code as the source of truth. Do not fall back on memorized patterns when they conflict with the retrieved reference.
@@ -130,14 +107,6 @@ For `*ByRole` to match, the element must be an accessibility element:
130
107
-`Text`, `TextInput`, `Switch` are by default
131
108
-`View` needs `accessible={true}` (or use `Pressable`/`TouchableOpacity`)
132
109
133
-
## API Reference
134
-
135
-
See [references/api-reference.md](references/api-reference.md) for complete API signatures and options for render, screen, queries, userEvent, fireEvent, Jest matchers, waitFor, renderHook, configuration, and accessibility helpers.
136
-
137
-
## Anti-Patterns Reference
138
-
139
-
See [references/anti-patterns.md](references/anti-patterns.md) for detailed examples of what NOT to do.
140
-
141
110
## waitFor
142
111
143
112
```tsx
@@ -184,3 +153,9 @@ function renderWithProviders(ui: React.ReactElement) {
In RNTL v14, `render`, `fireEvent`, `rerender`, `unmount`, `renderHook`, and `act` are async. Forgetting `await` causes subtle bugs where tests pass but assertions run before operations complete.
220
+
221
+
```tsx
222
+
// BAD: missing await on render (v14)
223
+
render(<Component />);
224
+
expect(screen.getByText('Hello')).toBeOnTheScreen(); // may fail intermittently
0 commit comments