@@ -503,6 +503,47 @@ declare namespace matchers {
503
503
* [testing-library/jest-dom#tohaveaccessibledescription](https://github.com/testing-library/jest-dom#tohaveaccessibledescription)
504
504
*/
505
505
toHaveAccessibleDescription ( text ?: string | RegExp | E ) : R ;
506
+
507
+ /**
508
+ * @description
509
+ * This allows you to assert that an element has the expected
510
+ * [accessible error message](https://w3c.github.io/aria/#aria-errormessage).
511
+ *
512
+ * You can pass the exact string of the expected accessible error message.
513
+ * Alternatively, you can perform a partial match by passing a regular expression
514
+ * or by using either
515
+ * [expect.stringContaining](https://jestjs.io/docs/en/expect.html#expectnotstringcontainingstring)
516
+ * or [expect.stringMatching](https://jestjs.io/docs/en/expect.html#expectstringmatchingstring-regexp).
517
+ *
518
+ * @example
519
+ * <input aria-label="Has Error" aria-invalid="true" aria-errormessage="error-message" />
520
+ * <div id="error-message" role="alert">This field is invalid</div>
521
+ *
522
+ * <input aria-label="No Error Attributes" />
523
+ * <input aria-label="Not Invalid" aria-invalid="false" aria-errormessage="error-message" />
524
+ *
525
+ * // Inputs with Valid Error Messages
526
+ * expect(getByRole('textbox', {name: 'Has Error'})).toHaveAccessibleErrorMessage()
527
+ * expect(getByRole('textbox', {name: 'Has Error'})).toHaveAccessibleErrorMessage('This field is invalid')
528
+ * expect(getByRole('textbox', {name: 'Has Error'})).toHaveAccessibleErrorMessage(/invalid/i)
529
+ * expect(
530
+ * getByRole('textbox', {name: 'Has Error'}),
531
+ * ).not.toHaveAccessibleErrorMessage('This field is absolutely correct!')
532
+ *
533
+ * // Inputs without Valid Error Messages
534
+ * expect(
535
+ * getByRole('textbox', {name: 'No Error Attributes'}),
536
+ * ).not.toHaveAccessibleErrorMessage()
537
+ *
538
+ * expect(
539
+ * getByRole('textbox', {name: 'Not Invalid'}),
540
+ * ).not.toHaveAccessibleErrorMessage()
541
+ *
542
+ * @see
543
+ * [testing-library/jest-dom#tohaveaccessibleerrormessage](https://github.com/testing-library/jest-dom#tohaveaccessibleerrormessage)
544
+ */
545
+ toHaveAccessibleErrorMessage ( text ?: string | RegExp | E ) : R ;
546
+
506
547
/**
507
548
* @description
508
549
* This allows to assert that an element has the expected [accessible name](https://w3c.github.io/accname/).
@@ -573,8 +614,10 @@ declare namespace matchers {
573
614
*/
574
615
toBePartiallyChecked ( ) : R ;
575
616
/**
576
- * @description
617
+ * @deprecated
618
+ * since v5.17.0
577
619
*
620
+ * @description
578
621
* Check whether the given element has an [ARIA error message](https://www.w3.org/TR/wai-aria/#aria-errormessage) or not.
579
622
*
580
623
* Use the `aria-errormessage` attribute to reference another element that contains
0 commit comments