Skip to content

Commit fd52043

Browse files
committed
remove redundant explanation of query vs get
1 parent 9a0250c commit fd52043

File tree

1 file changed

+9
-36
lines changed

1 file changed

+9
-36
lines changed

docs/api-queries.md

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@ title: Queries
1010
1111
### getBy
1212

13-
[`getBy*`](#query-apis) queries returns the first matching node for a query, and
14-
throw an error if no elements match.
13+
`getBy*` queries returns the first matching node for a query, and throws an
14+
error if no elements match.
1515

1616
### getAllBy
1717

18-
[`getAllBy*`](#queryall-and-getall-apis) queries return an array of all matching
19-
nodes for a query, and throw an error if no elements match.
18+
`getAllBy*` queries return an array of all matching nodes for a query, and
19+
throws an error if no elements match.
2020

2121
### queryBy
2222

23-
[`queryBy*`](#query-apis) queries returns the first matching node for a query,
24-
and return `null` if no elements match.
23+
`queryBy*` queries returns the first matching node for a query, and return
24+
`null` if no elements match. This is useful for asserting an element is not
25+
present.
2526

2627
### queryAllBy
2728

28-
[`queryAllBy*`](#queryall-and-getall-apis) queries return an array of all
29-
matching nodes for a query, and return an empty array (`[]`) if no elements
30-
match.
29+
`queryAllBy*`queries return an array of all matching nodes for a query, and
30+
return an empty array (`[]`) if no elements match.
3131

3232
## Options
3333

@@ -709,30 +709,3 @@ getByText(container, (content, element) => {
709709
return element.tagName.toLowerCase() === 'span' && content.startsWith('Hello')
710710
})
711711
```
712-
713-
## `query` APIs
714-
715-
Each of the `get` APIs listed in the [queries](#queries) section above have a
716-
complimentary `query` API. The `get` APIs will throw errors if a proper node
717-
cannot be found. This is normally the desired effect. However, if you want to
718-
make an assertion that an element is _not_ present in the DOM, then you can use
719-
the `query` API instead:
720-
721-
```javascript
722-
const submitButton = queryByText(container, 'submit')
723-
expect(submitButton).toBeNull() // it doesn't exist
724-
// or if you're using the custom matchers:
725-
expect(submitButton).not.toBeTruthy()
726-
```
727-
728-
## `queryAll` and `getAll` APIs
729-
730-
Each of the `query` APIs have a corresponsing `queryAll` version that always
731-
returns an Array of matching nodes. `getAll` is the same but throws when the
732-
array has a length of 0.
733-
734-
```javascript
735-
const submitButtons = queryAllByText(container, 'submit')
736-
expect(submitButtons).toHaveLength(3) // expect 3 elements
737-
expect(submitButtons[0]).toBeTruthy()
738-
```

0 commit comments

Comments
 (0)