Skip to content

Commit e59ab28

Browse files
chore: website rspress (#1868)
1 parent 9035fbc commit e59ab28

65 files changed

Lines changed: 1939 additions & 1840 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

website/docs/12.x/cookbook/basics/async-tests.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Typically, you would write synchronous tests, as they are simple and get the work done. However, there are cases when using asynchronous (async) tests might be necessary or beneficial. The two most common cases are:
66

77
1. **Testing Code with asynchronous operations**: When your code relies on asynchronous operations, such as network calls or database queries, async tests are essential. Even though you should mock these network calls, the mock should act similarly to the actual behavior and hence by async.
8-
2. **UserEvent API:** Using the [User Event API](docs/api/events/user-event) in your tests creates more realistic event handling. These interactions introduce delays (even though these are typically event-loop ticks with 0 ms delays), requiring async tests to handle the timing correctly.
8+
2. **UserEvent API:** Using the [User Event API](/docs/api/events/user-event) in your tests creates more realistic event handling. These interactions introduce delays (even though these are typically event-loop ticks with 0 ms delays), requiring async tests to handle the timing correctly.
99

1010
Using async tests when needed ensures your tests are reliable and simulate real-world conditions accurately.
1111

@@ -45,9 +45,9 @@ There are several asynchronous utilities you might use in your tests.
4545

4646
### `findBy*` queries
4747

48-
The most common are the [`findBy*` queries](docs/api/queries#find-by). These are useful when waiting for a matching element to appear. They can be understood as a [`getBy*` queries](docs/api/queries#get-by) used in conjunction with a [`waitFor` function](docs/api/misc/async#waitfor).
48+
The most common are the [`findBy*` queries](/docs/api/queries#find-by). These are useful when waiting for a matching element to appear. They can be understood as a [`getBy*` queries](/docs/api/queries#get-by) used in conjunction with a [`waitFor` function](/docs/api/misc/async#waitfor).
4949

50-
They accept the same predicates as `getBy*` queries like `findByRole`, `findByTest`, etc. They also have a multiple elements variant called [`findAllBy*`](docs/api/queries#find-all-by).
50+
They accept the same predicates as `getBy*` queries like `findByRole`, `findByTest`, etc. They also have a multiple elements variant called [`findAllBy*`](/docs/api/queries#find-all-by).
5151

5252
```typescript
5353
function findByRole: (
@@ -71,7 +71,7 @@ Each query has a default `timeout` value of 1000 ms and a default `interval` of
7171
const button = await screen.findByRole('button'), { name: 'Start' }, { timeout: 1000, interval: 50 });
7272
```
7373

74-
Alternatively, a default global `timeout` value can be set using the [`configure` function](docs/api/misc/config#configure):
74+
Alternatively, a default global `timeout` value can be set using the [`configure` function](/docs/api/misc/config#configure):
7575

7676
```typescript
7777
configure({ asyncUtilTimeout: timeout });
@@ -103,7 +103,7 @@ If you want to use it with `getBy*` queries, use the `findBy*` queries instead,
103103

104104
### `waitForElementToBeRemoved` function
105105

106-
A specialized function, [`waitForElementToBeRemoved`](docs/api/misc/async#waitforelementtoberemoved), is used to verify that a matching element was present but has since been removed.
106+
A specialized function, [`waitForElementToBeRemoved`](/docs/api/misc/async#waitforelementtoberemoved), is used to verify that a matching element was present but has since been removed.
107107

108108
```typescript
109109
function waitForElementToBeRemoved<T>(

website/docs/12.x/docs/api.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ uri: /api
66

77
React Native Testing Library consists of following APIs:
88

9-
- [`render` function](docs/api/render) - render your UI components for testing purposes
10-
- [`screen` object](docs/api/screen) - access rendered UI:
11-
- [Queries](docs/api/queries) - find relevant components by various predicates: role, text, test ids, etc
12-
- Lifecycle methods: [`rerender`](docs/api/screen#rerender), [`unmount`](docs/api/screen#unmount)
13-
- Helpers: [`debug`](docs/api/screen#debug), [`toJSON`](docs/api/screen#tojson), [`root`](docs/api/screen#root)
14-
- [Jest matchers](docs/api/jest-matchers) - validate assumptions about your UI
15-
- [User Event](docs/api/events/user-event) - simulate common user interactions like [`press`](docs/api/events/user-event#press) or [`type`](docs/api/events/user-event#type) in a realistic way
16-
- [Fire Event](docs/api/events/fire-event) - simulate any component event in a simplified way purposes
9+
- [`render` function](/docs/api/render) - render your UI components for testing purposes
10+
- [`screen` object](/docs/api/screen) - access rendered UI:
11+
- [Queries](/docs/api/queries) - find relevant components by various predicates: role, text, test ids, etc
12+
- Lifecycle methods: [`rerender`](/docs/api/screen#rerender), [`unmount`](/docs/api/screen#unmount)
13+
- Helpers: [`debug`](/docs/api/screen#debug), [`toJSON`](/docs/api/screen#tojson), [`root`](/docs/api/screen#root)
14+
- [Jest matchers](/docs/api/jest-matchers) - validate assumptions about your UI
15+
- [User Event](/docs/api/events/user-event) - simulate common user interactions like [`press`](/docs/api/events/user-event#press) or [`type`](/docs/api/events/user-event#type) in a realistic way
16+
- [Fire Event](/docs/api/events/fire-event) - simulate any component event in a simplified way purposes
1717
- Misc APIs:
18-
- [`renderHook` function](docs/api/misc/render-hook) - render hooks for testing
19-
- [Async utils](docs/api/misc/async): `findBy*` queries, `wait`, `waitForElementToBeRemoved`
20-
- [Configuration](docs/api/misc/config): `configure`, `resetToDefaults`
21-
- [Accessibility](docs/api/misc/accessibility): `isHiddenFromAccessibility`
22-
- [Other](docs/api/misc/other): `within`, `act`, `cleanup`
18+
- [`renderHook` function](/docs/api/misc/render-hook) - render hooks for testing
19+
- [Async utils](/docs/api/misc/async): `findBy*` queries, `wait`, `waitForElementToBeRemoved`
20+
- [Configuration](/docs/api/misc/config): `configure`, `resetToDefaults`
21+
- [Accessibility](/docs/api/misc/accessibility): `isHiddenFromAccessibility`
22+
- [Other](/docs/api/misc/other): `within`, `act`, `cleanup`

website/docs/12.x/docs/api/events/fire-event.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function fireEvent(element: ReactTestInstance, eventName: string, ...data: unkno
55
```
66

77
:::note
8-
For common events like `press` or `type` it's recommended to use [User Event API](docs/api/events/user-event) as it offers
8+
For common events like `press` or `type` it's recommended to use [User Event API](/docs/api/events/user-event) as it offers
99
more realistic event simulation by emitting a sequence of events with proper event objects that mimic React Native runtime behavior.
1010

1111
Use Fire Event for cases not supported by User Event and for triggering event handlers on composite components.
@@ -62,7 +62,7 @@ fireEvent.press: (element: ReactTestInstance, ...data: Array<any>) => void
6262
```
6363

6464
:::note
65-
It is recommended to use the User Event [`press()`](docs/api/events/user-event#press) helper instead as it offers more realistic simulation of press interaction, including pressable support.
65+
It is recommended to use the User Event [`press()`](/docs/api/events/user-event#press) helper instead as it offers more realistic simulation of press interaction, including pressable support.
6666
:::
6767

6868
Invokes `press` event handler on the element or parent element in the tree.
@@ -98,7 +98,7 @@ fireEvent.changeText: (element: ReactTestInstance, ...data: Array<any>) => void
9898
```
9999

100100
:::note
101-
It is recommended to use the User Event [`type()`](docs/api/events/user-event#type) helper instead as it offers more realistic simulation of text change interaction, including key-by-key typing, element focus, and other editing events.
101+
It is recommended to use the User Event [`type()`](/docs/api/events/user-event#type) helper instead as it offers more realistic simulation of text change interaction, including key-by-key typing, element focus, and other editing events.
102102
:::
103103

104104
Invokes `changeText` event handler on the element or parent element in the tree.
@@ -153,6 +153,6 @@ fireEvent.scroll(screen.getByText('scroll-view'), eventData);
153153

154154
:::note
155155

156-
Prefer using [`user.scrollTo`](docs/api/events/user-event#scrollto) over `fireEvent.scroll` for `ScrollView`, `FlatList`, and `SectionList` components. User Event provides a more realistic event simulation based on React Native runtime behavior.
156+
Prefer using [`user.scrollTo`](/docs/api/events/user-event#scrollto) over `fireEvent.scroll` for `ScrollView`, `FlatList`, and `SectionList` components. User Event provides a more realistic event simulation based on React Native runtime behavior.
157157

158158
:::

website/docs/12.x/docs/api/jest-matchers.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Alternatively, you can add above script to your Jest configuration (usually loca
2727

2828
## Migration from legacy Jest Native matchers.
2929

30-
If you are already using legacy Jest Native matchers we have a [migration guide](docs/migration/jest-matchers) for moving to the built-in matchers.
30+
If you are already using legacy Jest Native matchers we have a [migration guide](/docs/migration/jest-matchers) for moving to the built-in matchers.
3131

3232
## Checking element existence
3333

@@ -53,7 +53,7 @@ expect(element).toHaveTextContent(
5353
)
5454
```
5555

56-
This allows you to assert whether the given element has the given text content or not. It accepts either `string` or `RegExp` matchers, as well as [text match options](docs/api/queries#text-match-options) of `exact` and `normalizer`.
56+
This allows you to assert whether the given element has the given text content or not. It accepts either `string` or `RegExp` matchers, as well as [text match options](/docs/api/queries#text-match-options) of `exact` and `normalizer`.
5757

5858
### `toContainElement()`
5959

@@ -87,7 +87,7 @@ expect(element).toHaveDisplayValue(
8787
)
8888
```
8989

90-
This allows you to assert whether the given `TextInput` element has a specified display value. It accepts either `string` or `RegExp` matchers, as well as [text match options](docs/api/queries#text-match-options) of `exact` and `normalizer`.
90+
This allows you to assert whether the given `TextInput` element has a specified display value. It accepts either `string` or `RegExp` matchers, as well as [text match options](/docs/api/queries#text-match-options) of `exact` and `normalizer`.
9191

9292
### `toHaveAccessibilityValue()`
9393

@@ -202,7 +202,7 @@ expect(element).toHaveAccessibleName(
202202
)
203203
```
204204

205-
This allows you to assert whether the given element has a specified accessible name. It accepts either `string` or `RegExp` matchers, as well as [text match options](docs/api/queries#text-match-options) of `exact` and `normalizer`.
205+
This allows you to assert whether the given element has a specified accessible name. It accepts either `string` or `RegExp` matchers, as well as [text match options](/docs/api/queries#text-match-options) of `exact` and `normalizer`.
206206

207207
The accessible name will be computed based on `aria-labelledby`, `accessibilityLabelledBy`, `aria-label`, and `accessibilityLabel` props, in the absence of these props, the element text content will be used.
208208

website/docs/12.x/docs/api/misc/async.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## `findBy*` queries
44

5-
The `findBy*` queries are used to find elements that are not instantly available but will be added as a result of some asynchronous action. Learn more details [here](docs/api/queries#find-by).
5+
The `findBy*` queries are used to find elements that are not instantly available but will be added as a result of some asynchronous action. Learn more details [here](/docs/api/queries#find-by).
66

77
## `waitFor`
88

@@ -101,7 +101,7 @@ In order to properly use `waitFor` you need at least React >=16.9.0 (featuring a
101101
:::
102102

103103
:::note
104-
If you receive warnings related to `act()` function consult our [Understanding Act](docs/advanced/understanding-act.md) function document.
104+
If you receive warnings related to `act()` function consult our [Understanding Act](/docs/advanced/understanding-act.md) function document.
105105
:::
106106

107107
## `waitForElementToBeRemoved`
@@ -134,5 +134,5 @@ In order to properly use `waitForElementToBeRemoved` you need at least React >=1
134134
:::
135135

136136
:::note
137-
If you receive warnings related to `act()` function consult our [Understanding Act](docs/advanced/understanding-act.md) function document.
137+
If you receive warnings related to `act()` function consult our [Understanding Act](/docs/advanced/understanding-act.md) function document.
138138
:::

website/docs/12.x/docs/api/misc/config.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Default timeout, in ms, for async helper functions (`waitFor`, `waitForElementTo
1919

2020
### `defaultIncludeHiddenElements` option
2121

22-
Default value for [includeHiddenElements](docs/api/queries#includehiddenelements-option) query option for all queries. The default value is set to `false`, so all queries will not match [elements hidden from accessibility](#ishiddenfromaccessibility). This is because the users of the app would not be able to see such elements.
22+
Default value for [includeHiddenElements](/docs/api/queries#includehiddenelements-option) query option for all queries. The default value is set to `false`, so all queries will not match [elements hidden from accessibility](#ishiddenfromaccessibility). This is because the users of the app would not be able to see such elements.
2323

2424
This option is also available as `defaultHidden` alias for compatibility with [React Testing Library](https://testing-library.com/docs/dom-testing-library/api-configuration/#defaulthidden).
2525

website/docs/12.x/docs/api/misc/other.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function within(element: ReactTestInstance): Queries {}
88
function getQueriesForElement(element: ReactTestInstance): Queries {}
99
```
1010

11-
`within` (also available as `getQueriesForElement` alias) performs [queries](docs/api/queries) scoped to given element.
11+
`within` (also available as `getQueriesForElement` alias) performs [queries](/docs/api/queries) scoped to given element.
1212

1313
:::note
1414
Please note that additional `render` specific operations like `update`, `unmount`, `debug`, `toJSON` are _not_ included.
@@ -31,7 +31,7 @@ Use cases for scoped queries include:
3131

3232
Useful function to help testing components that use hooks API. By default any `render`, `update`, `fireEvent`, and `waitFor` calls are wrapped by this function, so there is no need to wrap it manually. This method is re-exported from [`react-test-renderer`](https://github.com/facebook/react/blob/main/packages/react-test-renderer/src/ReactTestRenderer.js#L567]).
3333

34-
Consult our [Understanding Act function](docs/advanced/understanding-act.md) document for more understanding of its intricacies.
34+
Consult our [Understanding Act function](/docs/advanced/understanding-act.md) document for more understanding of its intricacies.
3535

3636
## `cleanup`
3737

0 commit comments

Comments
 (0)