Skip to content

Commit 9ec1270

Browse files
docs: improve findBy docs by adding information about screen.debug() (#1268)
1 parent a49902b commit 9ec1270

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

website/docs/Queries.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ title: Queries
4444
4545
### getBy
4646

47-
`getBy*` queries return the first matching node for a query, and throw an error if no elements match or if more than one match is found (use `getAllBy` instead).
47+
`getBy*` queries return the first matching node for a query, and throw an error if no elements match or if more than one match is found. If you need to find more than one element, then use `getAllBy`.
4848

4949
### getAllBy
5050

@@ -56,22 +56,26 @@ title: Queries
5656

5757
### queryAllBy
5858

59-
`queryAllBy*` queries return an array of all matching nodes for a query, and return an empty array (`[]`) if no elements match.
59+
`queryAllBy*` queries return an array of all matching nodes for a query, and return an empty array (`[]`) when no elements match.
6060

6161
### findBy
6262

63-
`findBy` queries return a promise which resolves when a matching element is found. The promise is rejected if no elements match or if more than one match is found after a default timeout of 4500ms. If you need to find more than one element, then use `findAllBy`.
63+
`findBy` queries return a promise which resolves when a matching element is found. The promise is rejected if no elements match or if more than one match is found after a default timeout of 1000 ms. If you need to find more than one element, then use `findAllBy`.
6464

6565
### findAllBy
6666

67-
`findAllBy` queries return a promise which resolves to an array when any matching elements are found. The promise is rejected if no elements match after a default timeout of 4500ms.
67+
`findAllBy` queries return a promise which resolves to an array of matching elements. The promise is rejected if no elements match after a default timeout of 1000 ms.
6868

6969
:::info
70-
In order to properly use `findBy` and `findAllBy` queries you need at least React >=16.9.0 (featuring async `act`) or React Native >=0.61 (which comes with React >=16.9.0).
70+
`findBy` and `findAllBy` queries accept optional `waitForOptions` object argument which can contain `timeout`, `interval` and `onTimeout` properies which have the same meaning as respective options for [`waitFor`](api#waitfor) function.
7171
:::
7272

7373
:::info
74-
`findBy` and `findAllBy` queries accept optional `waitForOptions` object argument which can contain `timeout` and `interval` properies which have the same meaning as respective options for [`waitFor`](api#waitfor) function.
74+
In cases when your `findBy` and `findAllBy` queries throw when not able to find matching elements it is useful to pass `onTimeout: () => { screen.debug(); }` callback using `waitForOptions` parameter.
75+
:::
76+
77+
:::info
78+
In order to properly use `findBy` and `findAllBy` queries you need at least React >=16.9.0 (featuring async `act`) or React Native >=0.61 (which comes with React >=16.9.0).
7579
:::
7680

7781
## Queries
@@ -82,7 +86,7 @@ _Note: most methods like this one return a [`ReactTestInstance`](https://reactjs
8286
type ReactTestInstance = {
8387
type: string | Function;
8488
props: { [propName: string]: any };
85-
parent: null | ReactTestInstance;
89+
parent: ReactTestInstance | null;
8690
children: Array<ReactTestInstance | string>;
8791
};
8892
```

0 commit comments

Comments
 (0)