@@ -99,6 +99,10 @@ expect.extend({toBeInTheDOM, toHaveClass})
99
99
100
100
### ` toBeInTheDOM `
101
101
102
+ ``` typescript
103
+ toBeInTheDOM (container ?: HTMLElement )
104
+ ```
105
+
102
106
This allows you to assert whether an element present in the DOM container or not. If no DOM container is specified it will use the default DOM context.
103
107
104
108
#### Using the default DOM container
@@ -137,6 +141,10 @@ expect(queryByTestId(container, 'ancestor')).not.toBeInTheDOM(
137
141
138
142
### ` toBeEmpty `
139
143
144
+ ``` typescript
145
+ toBeEmpty ()
146
+ ```
147
+
140
148
This allows you to assert whether an element has content or not.
141
149
142
150
``` javascript
@@ -152,6 +160,10 @@ expect(queryByTestId(container, 'not-empty')).not.toBeEmpty()
152
160
153
161
### ` toContainElement `
154
162
163
+ ``` typescript
164
+ toContainElement (element : HTMLElement )
165
+ ```
166
+
155
167
This allows you to assert whether an element contains another element as a descendant or not.
156
168
157
169
``` javascript
@@ -170,6 +182,10 @@ expect(descendant).not.toContainElement(ancestor)
170
182
171
183
### ` toHaveTextContent `
172
184
185
+ ``` typescript
186
+ toHaveTextContent (text : string | RegExp )
187
+ ```
188
+
173
189
This API allows you to check whether the given element has a text content or not.
174
190
175
191
``` javascript
@@ -185,7 +201,11 @@ expect(getByTestId(container, 'count-value')).not.toHaveTextContent('21')
185
201
186
202
### ` toHaveAttribute `
187
203
188
- This allows you to check wether the given element has an attribute or not. You
204
+ ``` typescript
205
+ toHaveAttribute (attr : string , value ?: string )
206
+ ```
207
+
208
+ This allows you to check whether the given element has an attribute or not. You
189
209
can also optionally check that the attribute has a specific expected value.
190
210
191
211
``` javascript
@@ -207,7 +227,11 @@ expect(getByTestId(container, 'ok-button')).not.toHaveAttribute(
207
227
208
228
### ` toHaveClass `
209
229
210
- This allows you to check wether the given element has certain classes within its
230
+ ``` typescript
231
+ toHaveClass (... classNames : string [])
232
+ ```
233
+
234
+ This allows you to check whether the given element has certain classes within its
211
235
` class ` attribute.
212
236
213
237
``` javascript
@@ -227,6 +251,10 @@ expect(getByTestId(container, 'delete-button')).not.toHaveClass('btn-link')
227
251
228
252
### ` toHaveStyle `
229
253
254
+ ``` typescript
255
+ toHaveStyle (css : string )
256
+ ```
257
+
230
258
This allows you to check if a certain element has some specific css properties
231
259
with specific values applied. It matches only if the element has _ all_ the
232
260
expected properties applied, not just some of them.
@@ -257,6 +285,10 @@ The usual rules of css precedence apply.
257
285
258
286
### ` toHaveFocus `
259
287
288
+ ``` typescript
289
+ toHaveFocus ()
290
+ ```
291
+
260
292
This allows you to assert whether an element has focus or not.
261
293
262
294
``` javascript
@@ -279,6 +311,10 @@ expect(queryByTestId(container, 'focused')).not.toHaveFocus()
279
311
280
312
### ` toBeVisible `
281
313
314
+ ``` typescript
315
+ toBeVisible ()
316
+ ```
317
+
282
318
This allows you to check if an element is currently visible to the user.
283
319
284
320
An element is visible if ** all** the following conditions are met:
@@ -308,6 +344,10 @@ expect(container.querySelector('strong')).not.toBeVisible()
308
344
309
345
### ` toBeDisabled `
310
346
347
+ ``` typescript
348
+ toBeDisabled ()
349
+ ```
350
+
311
351
This allows you to check whether an element is disabled from the user's perspective.
312
352
313
353
It matches if the element is a form control and the ` disabled ` attribute is
0 commit comments