@najemi-software/vitest-dom 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/extend-expect.d.ts +1 -3
  2. package/dist/extend-expect.js +2 -6
  3. package/dist/extend-expect.js.map +1 -1
  4. package/dist/matchers/css-parse.d.ts +30 -0
  5. package/dist/matchers/css-parse.js +514 -0
  6. package/dist/matchers/css-parse.js.map +1 -0
  7. package/dist/matchers/to-be-checked.d.ts +2 -0
  8. package/dist/matchers/to-be-checked.js +52 -0
  9. package/dist/matchers/to-be-checked.js.map +1 -0
  10. package/dist/matchers/to-be-disabled.d.ts +3 -0
  11. package/dist/matchers/to-be-disabled.js +74 -0
  12. package/dist/matchers/to-be-disabled.js.map +1 -0
  13. package/dist/matchers/to-be-empty-dom-element.d.ts +2 -0
  14. package/dist/matchers/to-be-empty-dom-element.js +31 -0
  15. package/dist/matchers/to-be-empty-dom-element.js.map +1 -0
  16. package/dist/matchers/to-be-empty.d.ts +3 -0
  17. package/dist/matchers/to-be-empty.js +18 -0
  18. package/dist/matchers/to-be-empty.js.map +1 -0
  19. package/dist/matchers/to-be-in-the-document.d.ts +2 -0
  20. package/dist/matchers/to-be-in-the-document.js +24 -0
  21. package/dist/matchers/to-be-in-the-document.js.map +1 -0
  22. package/dist/matchers/to-be-in-the-dom.d.ts +3 -0
  23. package/dist/matchers/to-be-in-the-dom.js +23 -0
  24. package/dist/matchers/to-be-in-the-dom.js.map +1 -0
  25. package/dist/matchers/to-be-invalid.d.ts +3 -0
  26. package/dist/matchers/to-be-invalid.js +50 -0
  27. package/dist/matchers/to-be-invalid.js.map +1 -0
  28. package/dist/matchers/to-be-partially-checked.d.ts +2 -0
  29. package/dist/matchers/to-be-partially-checked.js +36 -0
  30. package/dist/matchers/to-be-partially-checked.js.map +1 -0
  31. package/dist/matchers/to-be-required.d.ts +2 -0
  32. package/dist/matchers/to-be-required.js +40 -0
  33. package/dist/matchers/to-be-required.js.map +1 -0
  34. package/dist/matchers/to-be-visible.d.ts +2 -0
  35. package/dist/matchers/to-be-visible.js +46 -0
  36. package/dist/matchers/to-be-visible.js.map +1 -0
  37. package/dist/matchers/to-contain-element.d.ts +2 -0
  38. package/dist/matchers/to-contain-element.js +19 -0
  39. package/dist/matchers/to-contain-element.js.map +1 -0
  40. package/dist/matchers/to-contain-html.d.ts +2 -0
  41. package/dist/matchers/to-contain-html.js +25 -0
  42. package/dist/matchers/to-contain-html.js.map +1 -0
  43. package/dist/matchers/to-have-accessible-description.d.ts +4 -0
  44. package/dist/matchers/to-have-accessible-description.js +28 -0
  45. package/dist/matchers/to-have-accessible-description.js.map +1 -0
  46. package/dist/matchers/to-have-accessible-errormessage.d.ts +2 -0
  47. package/dist/matchers/to-have-accessible-errormessage.js +48 -0
  48. package/dist/matchers/to-have-accessible-errormessage.js.map +1 -0
  49. package/dist/matchers/to-have-accessible-name.d.ts +3 -0
  50. package/dist/matchers/to-have-accessible-name.js +27 -0
  51. package/dist/matchers/to-have-accessible-name.js.map +1 -0
  52. package/dist/matchers/to-have-attribute.d.ts +2 -0
  53. package/dist/matchers/to-have-attribute.js +34 -0
  54. package/dist/matchers/to-have-attribute.js.map +1 -0
  55. package/dist/matchers/to-have-class.d.ts +2 -0
  56. package/dist/matchers/to-have-class.js +56 -0
  57. package/dist/matchers/to-have-class.js.map +1 -0
  58. package/dist/matchers/to-have-description.d.ts +4 -0
  59. package/dist/matchers/to-have-description.js +30 -0
  60. package/dist/matchers/to-have-description.js.map +1 -0
  61. package/dist/matchers/to-have-display-value.d.ts +2 -0
  62. package/dist/matchers/to-have-display-value.js +31 -0
  63. package/dist/matchers/to-have-display-value.js.map +1 -0
  64. package/dist/matchers/to-have-errormessage.d.ts +3 -0
  65. package/dist/matchers/to-have-errormessage.js +39 -0
  66. package/dist/matchers/to-have-errormessage.js.map +1 -0
  67. package/dist/matchers/to-have-focus.d.ts +2 -0
  68. package/dist/matchers/to-have-focus.js +22 -0
  69. package/dist/matchers/to-have-focus.js.map +1 -0
  70. package/dist/matchers/to-have-form-values.d.ts +2 -0
  71. package/dist/matchers/to-have-form-values.js +67 -0
  72. package/dist/matchers/to-have-form-values.js.map +1 -0
  73. package/dist/matchers/to-have-style.d.ts +2 -0
  74. package/dist/matchers/to-have-style.js +59 -0
  75. package/dist/matchers/to-have-style.js.map +1 -0
  76. package/dist/matchers/to-have-text-content.d.ts +4 -0
  77. package/dist/matchers/to-have-text-content.js +18 -0
  78. package/dist/matchers/to-have-text-content.js.map +1 -0
  79. package/dist/matchers/to-have-value.d.ts +2 -0
  80. package/dist/matchers/to-have-value.js +27 -0
  81. package/dist/matchers/to-have-value.js.map +1 -0
  82. package/dist/matchers/types.d.ts +13 -0
  83. package/dist/matchers/types.js +2 -0
  84. package/dist/matchers/types.js.map +1 -0
  85. package/dist/matchers/utils.d.ts +43 -0
  86. package/dist/matchers/utils.js +217 -0
  87. package/dist/matchers/utils.js.map +1 -0
  88. package/dist/matchers.d.ts +682 -83
  89. package/dist/matchers.js +25 -56
  90. package/dist/matchers.js.map +1 -1
  91. package/package.json +9 -5
  92. package/dist/chunk-DARZWRGS.js +0 -1546
  93. package/dist/chunk-DARZWRGS.js.map +0 -1
  94. package/dist/matchers-CEKfObS0.d.ts +0 -661
@@ -1,661 +0,0 @@
1
- import "vitest";
2
- interface TestingLibraryMatchers<E, R> extends Record<string, any> {
3
- /**
4
- * @deprecated
5
- * since v1.9.0
6
- * @description
7
- * Assert whether a value is a DOM element, or not. Contrary to what its name
8
- * implies, this matcher only checks that you passed to it a valid DOM
9
- * element.
10
- *
11
- * It does not have a clear definition of what "the DOM" is. Therefore, it
12
- * does not check whether that element is contained anywhere.
13
- * @see [testing-library/jest-dom#toBeInTheDom](https://github.com/testing-library/jest-dom#toBeInTheDom)
14
- */
15
- toBeInTheDOM(container?: HTMLElement | SVGElement): R;
16
- /**
17
- * @description
18
- * Assert whether an element is present in the document or not.
19
- * @example
20
- * <svg data-testid="svg-element"></svg>
21
- *
22
- * expect(queryByTestId('svg-element')).toBeInTheDocument()
23
- * expect(queryByTestId('does-not-exist')).not.toBeInTheDocument()
24
- * @see
25
- * [testing-library/jest-dom#tobeinthedocument](https://github.com/testing-library/jest-dom#tobeinthedocument)
26
- */
27
- toBeInTheDocument(): R;
28
- /**
29
- * @description
30
- * This allows you to check if an element is currently visible to the user.
31
- *
32
- * An element is visible if **all** the following conditions are met:
33
- * * it does not have its css property display set to none
34
- * * it does not have its css property visibility set to either hidden or collapse
35
- * * it does not have its css property opacity set to 0
36
- * * its parent element is also visible (and so on up to the top of the DOM tree)
37
- * * it does not have the hidden attribute
38
- * * if `<details />` it has the open attribute
39
- * @example
40
- * <div
41
- * data-testid="zero-opacity"
42
- * style="opacity: 0"
43
- * >
44
- * Zero Opacity
45
- * </div>
46
- *
47
- * <div data-testid="visible">Visible Example</div>
48
- *
49
- * expect(getByTestId('zero-opacity')).not.toBeVisible()
50
- * expect(getByTestId('visible')).toBeVisible()
51
- * @see
52
- * [testing-library/jest-dom#tobevisible](https://github.com/testing-library/jest-dom#tobevisible)
53
- */
54
- toBeVisible(): R;
55
- /**
56
- * @deprecated
57
- * since v5.9.0
58
- * @description
59
- * Assert whether an element has content or not.
60
- * @example
61
- * <span data-testid="not-empty">
62
- * <span data-testid="empty"></span>
63
- * </span>
64
- *
65
- * expect(getByTestId('empty')).toBeEmpty()
66
- * expect(getByTestId('not-empty')).not.toBeEmpty()
67
- * @see
68
- * [testing-library/jest-dom#tobeempty](https://github.com/testing-library/jest-dom#tobeempty)
69
- */
70
- toBeEmpty(): R;
71
- /**
72
- * @description
73
- * Assert whether an element has content or not.
74
- * @example
75
- * <span data-testid="not-empty">
76
- * <span data-testid="empty"></span>
77
- * </span>
78
- *
79
- * expect(getByTestId('empty')).toBeEmptyDOMElement()
80
- * expect(getByTestId('not-empty')).not.toBeEmptyDOMElement()
81
- * @see
82
- * [testing-library/jest-dom#tobeemptydomelement](https://github.com/testing-library/jest-dom#tobeemptydomelement)
83
- */
84
- toBeEmptyDOMElement(): R;
85
- /**
86
- * @description
87
- * Allows you to check whether an element is disabled from the user's perspective.
88
- *
89
- * Matches if the element is a form control and the `disabled` attribute is specified on this element or the
90
- * element is a descendant of a form element with a `disabled` attribute.
91
- * @example
92
- * <button
93
- * data-testid="button"
94
- * type="submit"
95
- * disabled
96
- * >
97
- * submit
98
- * </button>
99
- *
100
- * expect(getByTestId('button')).toBeDisabled()
101
- * @see
102
- * [testing-library/jest-dom#tobedisabled](https://github.com/testing-library/jest-dom#tobedisabled)
103
- */
104
- toBeDisabled(): R;
105
- /**
106
- * @description
107
- * Allows you to check whether an element is not disabled from the user's perspective.
108
- *
109
- * Works like `not.toBeDisabled()`.
110
- *
111
- * Use this matcher to avoid double negation in your tests.
112
- * @example
113
- * <button
114
- * data-testid="button"
115
- * type="submit"
116
- * >
117
- * submit
118
- * </button>
119
- *
120
- * expect(getByTestId('button')).toBeEnabled()
121
- * @see
122
- * [testing-library/jest-dom#tobeenabled](https://github.com/testing-library/jest-dom#tobeenabled)
123
- */
124
- toBeEnabled(): R;
125
- /**
126
- * @description
127
- * Check if a form element, or the entire `form`, is currently invalid.
128
- *
129
- * An `input`, `select`, `textarea`, or `form` element is invalid if it has an `aria-invalid` attribute with no
130
- * value or a value of "true", or if the result of `checkValidity()` is false.
131
- * @example
132
- * <input data-testid="no-aria-invalid" />
133
- *
134
- * <form data-testid="invalid-form">
135
- * <input required />
136
- * </form>
137
- *
138
- * expect(getByTestId('no-aria-invalid')).not.toBeInvalid()
139
- * expect(getByTestId('invalid-form')).toBeInvalid()
140
- * @see
141
- * [testing-library/jest-dom#tobeinvalid](https://github.com/testing-library/jest-dom#tobeinvalid)
142
- */
143
- toBeInvalid(): R;
144
- /**
145
- * @description
146
- * This allows you to check if a form element is currently required.
147
- *
148
- * An element is required if it is having a `required` or `aria-required="true"` attribute.
149
- * @example
150
- * <input data-testid="required-input" required />
151
- * <div
152
- * data-testid="supported-role"
153
- * role="tree"
154
- * required />
155
- *
156
- * expect(getByTestId('required-input')).toBeRequired()
157
- * expect(getByTestId('supported-role')).not.toBeRequired()
158
- * @see
159
- * [testing-library/jest-dom#toberequired](https://github.com/testing-library/jest-dom#toberequired)
160
- */
161
- toBeRequired(): R;
162
- /**
163
- * @description
164
- * Allows you to check if a form element is currently required.
165
- *
166
- * An `input`, `select`, `textarea`, or `form` element is invalid if it has an `aria-invalid` attribute with no
167
- * value or a value of "false", or if the result of `checkValidity()` is true.
168
- * @example
169
- * <input data-testid="aria-invalid" aria-invalid />
170
- *
171
- * <form data-testid="valid-form">
172
- * <input />
173
- * </form>
174
- *
175
- * expect(getByTestId('no-aria-invalid')).not.toBeValid()
176
- * expect(getByTestId('invalid-form')).toBeInvalid()
177
- * @see
178
- * [testing-library/jest-dom#tobevalid](https://github.com/testing-library/jest-dom#tobevalid)
179
- */
180
- toBeValid(): R;
181
- /**
182
- * @description
183
- * Allows you to assert whether an element contains another element as a descendant or not.
184
- * @example
185
- * <span data-testid="ancestor">
186
- * <span data-testid="descendant"></span>
187
- * </span>
188
- *
189
- * const ancestor = getByTestId('ancestor')
190
- * const descendant = getByTestId('descendant')
191
- * const nonExistantElement = getByTestId('does-not-exist')
192
- * expect(ancestor).toContainElement(descendant)
193
- * expect(descendant).not.toContainElement(ancestor)
194
- * expect(ancestor).not.toContainElement(nonExistantElement)
195
- * @see
196
- * [testing-library/jest-dom#tocontainelement](https://github.com/testing-library/jest-dom#tocontainelement)
197
- */
198
- toContainElement(element: HTMLElement | SVGElement | null): R;
199
- /**
200
- * @description
201
- * Assert whether a string representing a HTML element is contained in another element.
202
- * @example
203
- * <span data-testid="parent"><span data-testid="child"></span></span>
204
- *
205
- * expect(getByTestId('parent')).toContainHTML('<span data-testid="child"></span>')
206
- * @see
207
- * [testing-library/jest-dom#tocontainhtml](https://github.com/testing-library/jest-dom#tocontainhtml)
208
- */
209
- toContainHTML(htmlText: string): R;
210
- /**
211
- * @description
212
- * Allows you to check if a given element has an attribute or not.
213
- *
214
- * You can also optionally check that the attribute has a specific expected value or partial match using
215
- * [expect.stringContaining](https://jestjs.io/docs/en/expect.html#expectnotstringcontainingstring) or
216
- * [expect.stringMatching](https://jestjs.io/docs/en/expect.html#expectstringmatchingstring-regexp).
217
- * @example
218
- * <button
219
- * data-testid="ok-button"
220
- * type="submit"
221
- * disabled
222
- * >
223
- * ok
224
- * </button>
225
- *
226
- * expect(button).toHaveAttribute('disabled')
227
- * expect(button).toHaveAttribute('type', 'submit')
228
- * expect(button).not.toHaveAttribute('type', 'button')
229
- * @see
230
- * [testing-library/jest-dom#tohaveattribute](https://github.com/testing-library/jest-dom#tohaveattribute)
231
- */
232
- toHaveAttribute(attr: string, value?: unknown): R;
233
- /**
234
- * @description
235
- * Check whether the given element has certain classes within its `class` attribute.
236
- *
237
- * You must provide at least one class, unless you are asserting that an element does not have any classes.
238
- * @example
239
- * <button
240
- * data-testid="delete-button"
241
- * class="btn xs btn-danger"
242
- * >
243
- * delete item
244
- * </button>
245
- *
246
- * <div data-testid="no-classes">no classes</div>
247
- *
248
- * const deleteButton = getByTestId('delete-button')
249
- * const noClasses = getByTestId('no-classes')
250
- * expect(deleteButton).toHaveClass('btn')
251
- * expect(deleteButton).toHaveClass('btn-danger xs')
252
- * expect(deleteButton).toHaveClass('btn xs btn-danger', {exact: true})
253
- * expect(deleteButton).not.toHaveClass('btn xs btn-danger', {exact: true})
254
- * expect(noClasses).not.toHaveClass()
255
- * @see
256
- * [testing-library/jest-dom#tohaveclass](https://github.com/testing-library/jest-dom#tohaveclass)
257
- */
258
- toHaveClass(...classNames: string[]): R;
259
- toHaveClass(classNames: string, options?: {
260
- exact: boolean;
261
- }): R;
262
- /**
263
- * @description
264
- * This allows you to check whether the given form element has the specified displayed value (the one the
265
- * end user will see). It accepts <input>, <select> and <textarea> elements with the exception of <input type="checkbox">
266
- * and <input type="radio">, which can be meaningfully matched only using toBeChecked or toHaveFormValues.
267
- * @example
268
- * <label for="input-example">First name</label>
269
- * <input type="text" id="input-example" value="Luca" />
270
- *
271
- * <label for="textarea-example">Description</label>
272
- * <textarea id="textarea-example">An example description here.</textarea>
273
- *
274
- * <label for="single-select-example">Fruit</label>
275
- * <select id="single-select-example">
276
- * <option value="">Select a fruit...</option>
277
- * <option value="banana">Banana</option>
278
- * <option value="ananas">Ananas</option>
279
- * <option value="avocado">Avocado</option>
280
- * </select>
281
- *
282
- * <label for="mutiple-select-example">Fruits</label>
283
- * <select id="multiple-select-example" multiple>
284
- * <option value="">Select a fruit...</option>
285
- * <option value="banana" selected>Banana</option>
286
- * <option value="ananas">Ananas</option>
287
- * <option value="avocado" selected>Avocado</option>
288
- * </select>
289
- *
290
- * const input = screen.getByLabelText('First name')
291
- * const textarea = screen.getByLabelText('Description')
292
- * const selectSingle = screen.getByLabelText('Fruit')
293
- * const selectMultiple = screen.getByLabelText('Fruits')
294
- *
295
- * expect(input).toHaveDisplayValue('Luca')
296
- * expect(textarea).toHaveDisplayValue('An example description here.')
297
- * expect(selectSingle).toHaveDisplayValue('Select a fruit...')
298
- * expect(selectMultiple).toHaveDisplayValue(['Banana', 'Avocado'])
299
- *
300
- * @see
301
- * [testing-library/jest-dom#tohavedisplayvalue](https://github.com/testing-library/jest-dom#tohavedisplayvalue)
302
- */
303
- toHaveDisplayValue(value: string | RegExp | Array<string | RegExp>): R;
304
- /**
305
- * @description
306
- * Assert whether an element has focus or not.
307
- * @example
308
- * <div>
309
- * <input type="text" data-testid="element-to-focus" />
310
- * </div>
311
- *
312
- * const input = getByTestId('element-to-focus')
313
- * input.focus()
314
- * expect(input).toHaveFocus()
315
- * input.blur()
316
- * expect(input).not.toHaveFocus()
317
- * @see
318
- * [testing-library/jest-dom#tohavefocus](https://github.com/testing-library/jest-dom#tohavefocus)
319
- */
320
- toHaveFocus(): R;
321
- /**
322
- * @description
323
- * Check if a form or fieldset contains form controls for each given name, and having the specified value.
324
- *
325
- * Can only be invoked on a form or fieldset element.
326
- * @example
327
- * <form data-testid="login-form">
328
- * <input type="text" name="username" value="jane.doe" />
329
- * <input type="password" name="password" value="123" />
330
- * <input type="checkbox" name="rememberMe" checked />
331
- * <button type="submit">Sign in</button>
332
- * </form>
333
- *
334
- * expect(getByTestId('login-form')).toHaveFormValues({
335
- * username: 'jane.doe',
336
- * rememberMe: true,
337
- * })
338
- * @see
339
- * [testing-library/jest-dom#tohaveformvalues](https://github.com/testing-library/jest-dom#tohaveformvalues)
340
- */
341
- toHaveFormValues(expectedValues: Record<string, unknown>): R;
342
- /**
343
- * @description
344
- * Check if an element has specific css properties with specific values applied.
345
- *
346
- * Only matches if the element has *all* the expected properties applied, not just some of them.
347
- * @example
348
- * <button
349
- * data-test-id="submit-button"
350
- * style="background-color: green; display: none"
351
- * >
352
- * submit
353
- * </button>
354
- *
355
- * const button = getByTestId('submit-button')
356
- * expect(button).toHaveStyle('background-color: green')
357
- * expect(button).toHaveStyle({
358
- * 'background-color': 'green',
359
- * display: 'none'
360
- * })
361
- * @see
362
- * [testing-library/jest-dom#tohavestyle](https://github.com/testing-library/jest-dom#tohavestyle)
363
- */
364
- toHaveStyle(css: string | Record<string, unknown>): R;
365
- /**
366
- * @description
367
- * Check whether the given element has a text content or not.
368
- *
369
- * When a string argument is passed through, it will perform a partial case-sensitive match to the element
370
- * content.
371
- *
372
- * To perform a case-insensitive match, you can use a RegExp with the `/i` modifier.
373
- *
374
- * If you want to match the whole content, you can use a RegExp to do it.
375
- * @example
376
- * <span data-testid="text-content">Text Content</span>
377
- *
378
- * const element = getByTestId('text-content')
379
- * expect(element).toHaveTextContent('Content')
380
- * // to match the whole content
381
- * expect(element).toHaveTextContent(/^Text Content$/)
382
- * // to use case-insentive match
383
- * expect(element).toHaveTextContent(/content$/i)
384
- * expect(element).not.toHaveTextContent('content')
385
- * @see
386
- * [testing-library/jest-dom#tohavetextcontent](https://github.com/testing-library/jest-dom#tohavetextcontent)
387
- */
388
- toHaveTextContent(text: string | RegExp, options?: {
389
- normalizeWhitespace: boolean;
390
- }): R;
391
- /**
392
- * @description
393
- * Check whether the given form element has the specified value.
394
- *
395
- * Accepts `<input>`, `<select>`, and `<textarea>` elements with the exception of `<input type="checkbox">` and
396
- * `<input type="radiobox">`, which can be matched only using
397
- * [toBeChecked](https://github.com/testing-library/jest-dom#tobechecked) or
398
- * [toHaveFormValues](https://github.com/testing-library/jest-dom#tohaveformvalues).
399
- * @example
400
- * <input
401
- * type="number"
402
- * value="5"
403
- * data-testid="input-number" />
404
- *
405
- * const numberInput = getByTestId('input-number')
406
- * expect(numberInput).toHaveValue(5)
407
- * @see
408
- * [testing-library/jest-dom#tohavevalue](https://github.com/testing-library/jest-dom#tohavevalue)
409
- */
410
- toHaveValue(value?: string | string[] | number | null): R;
411
- /**
412
- * @description
413
- * Assert whether the given element is checked.
414
- *
415
- * It accepts an `input` of type `checkbox` or `radio` and elements with a `role` of `radio` with a valid
416
- * `aria-checked` attribute of "true" or "false".
417
- * @example
418
- * <input
419
- * type="checkbox"
420
- * checked
421
- * data-testid="input-checkbox" />
422
- * <input
423
- * type="radio"
424
- * value="foo"
425
- * data-testid="input-radio" />
426
- *
427
- * const inputCheckbox = getByTestId('input-checkbox')
428
- * const inputRadio = getByTestId('input-radio')
429
- * expect(inputCheckbox).toBeChecked()
430
- * expect(inputRadio).not.toBeChecked()
431
- * @see
432
- * [testing-library/jest-dom#tobechecked](https://github.com/testing-library/jest-dom#tobechecked)
433
- */
434
- toBeChecked(): R;
435
- /**
436
- * @deprecated
437
- * since v5.14.1
438
- * @description
439
- * Check the accessible description for an element.
440
- * This allows you to check whether the given element has a description or not.
441
- *
442
- * An element gets its description via the
443
- * [`aria-describedby` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-describedby_attribute).
444
- * Set this to the `id` of one or more other elements. These elements may be nested
445
- * inside, be outside, or a sibling of the passed in element.
446
- *
447
- * Whitespace is normalized. Using multiple ids will
448
- * [join the referenced elements’ text content separated by a space](https://www.w3.org/TR/accname-1.1/#mapping_additional_nd_description).
449
- *
450
- * When a `string` argument is passed through, it will perform a whole
451
- * case-sensitive match to the description text.
452
- *
453
- * To perform a case-insensitive match, you can use a `RegExp` with the `/i`
454
- * modifier.
455
- *
456
- * To perform a partial match, you can pass a `RegExp` or use
457
- * `expect.stringContaining("partial string")`.
458
- *
459
- * @example
460
- * <button aria-label="Close" aria-describedby="description-close">
461
- * X
462
- * </button>
463
- * <div id="description-close">
464
- * Closing will discard any changes
465
- * </div>
466
- *
467
- * <button>Delete</button>
468
- *
469
- * const closeButton = getByRole('button', {name: 'Close'})
470
- *
471
- * expect(closeButton).toHaveDescription('Closing will discard any changes')
472
- * expect(closeButton).toHaveDescription(/will discard/) // to partially match
473
- * expect(closeButton).toHaveDescription(expect.stringContaining('will discard')) // to partially match
474
- * expect(closeButton).toHaveDescription(/^closing/i) // to use case-insensitive match
475
- * expect(closeButton).not.toHaveDescription('Other description')
476
- *
477
- * const deleteButton = getByRole('button', {name: 'Delete'})
478
- * expect(deleteButton).not.toHaveDescription()
479
- * expect(deleteButton).toHaveDescription('') // Missing or empty description always becomes a blank string
480
- * @see
481
- * [testing-library/jest-dom#tohavedescription](https://github.com/testing-library/jest-dom#tohavedescription)
482
- */
483
- toHaveDescription(text?: string | RegExp | E): R;
484
- /**
485
- * @description
486
- * This allows to assert that an element has the expected [accessible description](https://w3c.github.io/accname/).
487
- *
488
- * You can pass the exact string of the expected accessible description, or you can make a
489
- * partial match passing a regular expression, or by using either
490
- * [expect.stringContaining](https://jestjs.io/docs/en/expect.html#expectnotstringcontainingstring)
491
- * or [expect.stringMatching](https://jestjs.io/docs/en/expect.html#expectstringmatchingstring-regexp).
492
- * @example
493
- * <a data-testid="link" href="/" aria-label="Home page" title="A link to start over">Start</a>
494
- * <a data-testid="extra-link" href="/about" aria-label="About page">About</a>
495
- * <img src="avatar.jpg" data-testid="avatar" alt="User profile pic" />
496
- * <img src="logo.jpg" data-testid="logo" alt="Company logo" aria-describedby="t1" />
497
- * <span id="t1" role="presentation">The logo of Our Company</span>
498
- *
499
- * expect(getByTestId('link')).toHaveAccessibleDescription()
500
- * expect(getByTestId('link')).toHaveAccessibleDescription('A link to start over')
501
- * expect(getByTestId('link')).not.toHaveAccessibleDescription('Home page')
502
- * expect(getByTestId('extra-link')).not.toHaveAccessibleDescription()
503
- * expect(getByTestId('avatar')).not.toHaveAccessibleDescription()
504
- * expect(getByTestId('logo')).not.toHaveAccessibleDescription('Company logo')
505
- * expect(getByTestId('logo')).toHaveAccessibleDescription('The logo of Our Company')
506
- * @see
507
- * [testing-library/jest-dom#tohaveaccessibledescription](https://github.com/testing-library/jest-dom#tohaveaccessibledescription)
508
- */
509
- toHaveAccessibleDescription(text?: string | RegExp | E): R;
510
- /**
511
- * @description
512
- * This allows you to assert that an element has the expected
513
- * [accessible error message](https://w3c.github.io/aria/#aria-errormessage).
514
- *
515
- * You can pass the exact string of the expected accessible error message.
516
- * Alternatively, you can perform a partial match by passing a regular expression
517
- * or by using either
518
- * [expect.stringContaining](https://jestjs.io/docs/en/expect.html#expectnotstringcontainingstring)
519
- * or [expect.stringMatching](https://jestjs.io/docs/en/expect.html#expectstringmatchingstring-regexp).
520
- *
521
- * @example
522
- * <input aria-label="Has Error" aria-invalid="true" aria-errormessage="error-message" />
523
- * <div id="error-message" role="alert">This field is invalid</div>
524
- *
525
- * <input aria-label="No Error Attributes" />
526
- * <input aria-label="Not Invalid" aria-invalid="false" aria-errormessage="error-message" />
527
- *
528
- * // Inputs with Valid Error Messages
529
- * expect(getByRole('textbox', {name: 'Has Error'})).toHaveAccessibleErrorMessage()
530
- * expect(getByRole('textbox', {name: 'Has Error'})).toHaveAccessibleErrorMessage('This field is invalid')
531
- * expect(getByRole('textbox', {name: 'Has Error'})).toHaveAccessibleErrorMessage(/invalid/i)
532
- * expect(
533
- * getByRole('textbox', {name: 'Has Error'}),
534
- * ).not.toHaveAccessibleErrorMessage('This field is absolutely correct!')
535
- *
536
- * // Inputs without Valid Error Messages
537
- * expect(
538
- * getByRole('textbox', {name: 'No Error Attributes'}),
539
- * ).not.toHaveAccessibleErrorMessage()
540
- *
541
- * expect(
542
- * getByRole('textbox', {name: 'Not Invalid'}),
543
- * ).not.toHaveAccessibleErrorMessage()
544
- *
545
- * @see
546
- * [testing-library/jest-dom#tohaveaccessibleerrormessage](https://github.com/testing-library/jest-dom#tohaveaccessibleerrormessage)
547
- */
548
- toHaveAccessibleErrorMessage(text?: string | RegExp | E): R;
549
- /**
550
- * @description
551
- * This allows to assert that an element has the expected [accessible name](https://w3c.github.io/accname/).
552
- * It is useful, for instance, to assert that form elements and buttons are properly labelled.
553
- *
554
- * You can pass the exact string of the expected accessible name, or you can make a
555
- * partial match passing a regular expression, or by using either
556
- * [expect.stringContaining](https://jestjs.io/docs/en/expect.html#expectnotstringcontainingstring)
557
- * or [expect.stringMatching](https://jestjs.io/docs/en/expect.html#expectstringmatchingstring-regexp).
558
- * @example
559
- * <img data-testid="img-alt" src="" alt="Test alt" />
560
- * <img data-testid="img-empty-alt" src="" alt="" />
561
- * <svg data-testid="svg-title"><title>Test title</title></svg>
562
- * <button data-testid="button-img-alt"><img src="" alt="Test" /></button>
563
- * <p><img data-testid="img-paragraph" src="" alt="" /> Test content</p>
564
- * <button data-testid="svg-button"><svg><title>Test</title></svg></p>
565
- * <div><svg data-testid="svg-without-title"></svg></div>
566
- * <input data-testid="input-title" title="test" />
567
- *
568
- * expect(getByTestId('img-alt')).toHaveAccessibleName('Test alt')
569
- * expect(getByTestId('img-empty-alt')).not.toHaveAccessibleName()
570
- * expect(getByTestId('svg-title')).toHaveAccessibleName('Test title')
571
- * expect(getByTestId('button-img-alt')).toHaveAccessibleName()
572
- * expect(getByTestId('img-paragraph')).not.toHaveAccessibleName()
573
- * expect(getByTestId('svg-button')).toHaveAccessibleName()
574
- * expect(getByTestId('svg-without-title')).not.toHaveAccessibleName()
575
- * expect(getByTestId('input-title')).toHaveAccessibleName()
576
- * @see
577
- * [testing-library/jest-dom#tohaveaccessiblename](https://github.com/testing-library/jest-dom#tohaveaccessiblename)
578
- */
579
- toHaveAccessibleName(text?: string | RegExp | E): R;
580
- /**
581
- * @description
582
- * This allows you to check whether the given element is partially checked.
583
- * It accepts an input of type checkbox and elements with a role of checkbox
584
- * with a aria-checked="mixed", or input of type checkbox with indeterminate
585
- * set to true
586
- *
587
- * @example
588
- * <input type="checkbox" aria-checked="mixed" data-testid="aria-checkbox-mixed" />
589
- * <input type="checkbox" checked data-testid="input-checkbox-checked" />
590
- * <input type="checkbox" data-testid="input-checkbox-unchecked" />
591
- * <div role="checkbox" aria-checked="true" data-testid="aria-checkbox-checked" />
592
- * <div
593
- * role="checkbox"
594
- * aria-checked="false"
595
- * data-testid="aria-checkbox-unchecked"
596
- * />
597
- * <input type="checkbox" data-testid="input-checkbox-indeterminate" />
598
- *
599
- * const ariaCheckboxMixed = getByTestId('aria-checkbox-mixed')
600
- * const inputCheckboxChecked = getByTestId('input-checkbox-checked')
601
- * const inputCheckboxUnchecked = getByTestId('input-checkbox-unchecked')
602
- * const ariaCheckboxChecked = getByTestId('aria-checkbox-checked')
603
- * const ariaCheckboxUnchecked = getByTestId('aria-checkbox-unchecked')
604
- * const inputCheckboxIndeterminate = getByTestId('input-checkbox-indeterminate')
605
- *
606
- * expect(ariaCheckboxMixed).toBePartiallyChecked()
607
- * expect(inputCheckboxChecked).not.toBePartiallyChecked()
608
- * expect(inputCheckboxUnchecked).not.toBePartiallyChecked()
609
- * expect(ariaCheckboxChecked).not.toBePartiallyChecked()
610
- * expect(ariaCheckboxUnchecked).not.toBePartiallyChecked()
611
- *
612
- * inputCheckboxIndeterminate.indeterminate = true
613
- * expect(inputCheckboxIndeterminate).toBePartiallyChecked()
614
- * @see
615
- * [testing-library/jest-dom#tobepartiallychecked](https://github.com/testing-library/jest-dom#tobepartiallychecked)
616
- */
617
- toBePartiallyChecked(): R;
618
- /**
619
- * @description
620
- *
621
- * Check whether the given element has an [ARIA error message](https://www.w3.org/TR/wai-aria/#aria-errormessage) or not.
622
- *
623
- * Use the `aria-errormessage` attribute to reference another element that contains
624
- * custom error message text. Multiple ids is **NOT** allowed. Authors MUST use
625
- * `aria-invalid` in conjunction with `aria-errormessage`. Learn more from the
626
- * [`aria-errormessage` spec](https://www.w3.org/TR/wai-aria/#aria-errormessage).
627
- *
628
- * Whitespace is normalized.
629
- *
630
- * When a `string` argument is passed through, it will perform a whole
631
- * case-sensitive match to the error message text.
632
- *
633
- * To perform a case-insensitive match, you can use a `RegExp` with the `/i`
634
- * modifier.
635
- *
636
- * To perform a partial match, you can pass a `RegExp` or use
637
- * expect.stringContaining("partial string")`.
638
- *
639
- * @example
640
- * <label for="startTime"> Please enter a start time for the meeting: </label>
641
- * <input id="startTime" type="text" aria-errormessage="msgID" aria-invalid="true" value="11:30 PM" />
642
- * <span id="msgID" aria-live="assertive" style="visibility:visible">
643
- * Invalid time: the time must be between 9:00 AM and 5:00 PM"
644
- * </span>
645
- *
646
- *
647
- * const timeInput = getByLabel('startTime')
648
- *
649
- * expect(timeInput).toHaveErrorMessage(
650
- * 'Invalid time: the time must be between 9:00 AM and 5:00 PM',
651
- * )
652
- * expect(timeInput).toHaveErrorMessage(/invalid time/i) // to partially match
653
- * expect(timeInput).toHaveErrorMessage(expect.stringContaining('Invalid time')) // to partially match
654
- * expect(timeInput).not.toHaveErrorMessage('Pikachu!')
655
- * @see
656
- * [testing-library/jest-dom#tohaveerrormessage](https://github.com/testing-library/jest-dom#tohaveerrormessage)
657
- */
658
- toHaveErrorMessage(text?: string | RegExp | E): R;
659
- }
660
-
661
- export type { TestingLibraryMatchers as T };