Skip to content

Commit 8a90ebd

Browse files
committed
llm guidelines improvement
1 parent 1240b85 commit 8a90ebd

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

website/docs/13.x/docs/guides/llm-guidelines.mdx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,53 @@
22

33
Actionable guidelines for writing tests with React Native Testing Library (RNTL) v13.
44

5+
## Core APIs
6+
7+
### render
8+
9+
```tsx
10+
const result = render(<Component />, options?); // Sync in v13
11+
```
12+
13+
| Option | Description |
14+
|--------|-------------|
15+
| `wrapper` | React component to wrap the rendered component (e.g., providers) |
16+
| `createNodeMock` | Function to create mock refs |
17+
18+
| Return | Description |
19+
|--------|-------------|
20+
| `rerender(component)` | Re-render with a new component |
21+
| `unmount()` | Unmount the rendered component |
22+
| `toJSON()` | Get JSON representation for snapshots |
23+
| `debug(options?)` | Print the component tree to console |
24+
| `root` | Root element of the rendered component |
25+
26+
### screen
27+
28+
**Prefer `screen`** over destructuring from `render()`. Provides all query methods after `render()` is called.
29+
30+
```tsx
31+
render(<Component />);
32+
screen.getByRole('button'); // Access queries via screen
33+
```
34+
35+
### renderHook
36+
37+
```tsx
38+
const { result, rerender, unmount } = renderHook(() => useMyHook(), options?); // Sync in v13
39+
```
40+
41+
| Option | Description |
42+
|--------|-------------|
43+
| `initialProps` | Initial props passed to the hook |
44+
| `wrapper` | React component to wrap the hook (e.g., providers) |
45+
46+
| Return | Description |
47+
|--------|-------------|
48+
| `result.current` | Current return value of the hook |
49+
| `rerender(props?)` | Re-render hook with new props |
50+
| `unmount()` | Unmount the hook |
51+
552
## Query Selection
653
754
- **Prefer `getByRole`** as first choice for querying elements

website/docs/14.x/docs/guides/llm-guidelines.mdx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,54 @@
22

33
Actionable guidelines for writing tests with React Native Testing Library (RNTL) v14.
44

5+
## Core APIs
6+
7+
### render
8+
9+
```tsx
10+
const result = await render(<Component />, options?);
11+
```
12+
13+
| Option | Description |
14+
|--------|-------------|
15+
| `wrapper` | React component to wrap the rendered component (e.g., providers) |
16+
| `createNodeMock` | Function to create mock refs |
17+
18+
| Return | Description |
19+
|--------|-------------|
20+
| `rerender(component)` | Re-render with a new component (async) |
21+
| `unmount()` | Unmount the rendered component (async) |
22+
| `toJSON()` | Get JSON representation for snapshots |
23+
| `debug(options?)` | Print the component tree to console |
24+
| `container` | Root host element of the rendered tree |
25+
| `root` | First child host element (your component's root) |
26+
27+
### screen
28+
29+
**Prefer `screen`** over destructuring from `render()`. Provides all query methods after `render()` is called.
30+
31+
```tsx
32+
await render(<Component />);
33+
screen.getByRole('button'); // Access queries via screen
34+
```
35+
36+
### renderHook
37+
38+
```tsx
39+
const { result, rerender, unmount } = await renderHook(() => useMyHook(), options?);
40+
```
41+
42+
| Option | Description |
43+
|--------|-------------|
44+
| `initialProps` | Initial props passed to the hook |
45+
| `wrapper` | React component to wrap the hook (e.g., providers) |
46+
47+
| Return | Description |
48+
|--------|-------------|
49+
| `result.current` | Current return value of the hook |
50+
| `rerender(props?)` | Re-render hook with new props (async) |
51+
| `unmount()` | Unmount the hook (async) |
52+
553
## Query Selection
654
755
- **Prefer `getByRole`** as first choice for querying elements

0 commit comments

Comments
 (0)