Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign uptoHaveErrorMessage #256
toHaveErrorMessage #256
Comments
|
Sure, this is really nice. Also, "Today I Learned" that this attribute and aria feature even existed. Thanks! In reading the spec for this attribute, yes, you are right that this matcher should assert that Another thing that caught my eye from the spec is that the referenced element that holds the error message should be visible (screen reader visible at least). So I think the matcher should also validate that the referenced element does not have But I think it does not hurt we still include the check. At the very least, we'd help authors catch the case where they hide/show the element by applying In any case, I'm happy to take this myself, but I won't have time until about the next weekend or the other one. If you or anyone else is up to it, feel free to take a crack at it. Thanks! |
|
I'm down to write up an initial PR for review to cover at least the error message and invalid assertion. If we include within scope that the error message be visible, is that as simple as calling |
|
I'm ok with leaving that part of the spec out of the initial version. But leaving it to a separate assertion would require the user writing the tests to grab that element's reference first, which would make it cumbersome and not something with which this assertion would be helping with. They' need to get into the implementation details that this new custom matcher would be trying to give them. But yes, feel free to ignore that part. We can always improve it later. |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

Describe the feature you'd like:
I'd like an assertion for the
aria-errormessageattribute. It accepts a list of id strings formatted identically to the formataria-describedbyaccepts.https://www.w3.org/TR/wai-aria-1.1/#aria-errormessage
Browser support was poor a year ago but I can't seem to find any up-to-date information on its support level. There is some chance that this is unsupported enough to be not worth implementing, but on a long enough timeline I think it'll fit well here.
Usage
Suggested implementation:
The implementation would be nearly a clone of
toHaveDescriptionexcept the elements it reads come from thearia-errormessageattribute instead ofaria-describedbyIt could also assert that
aria-invalidis trueI'm willing to make a PR for inclusion but I'm new to open source so I wanted to get feedback up front
Describe alternatives you've considered:
Teachability, Documentation, Adoption, Migration Strategy:
toHaveErrorMessageThis allows you to check whether the given element has an error message or not.
An element gets its error message via the
aria-errormessageattribute.Set this to the
idof one or more other elements. These elements may be nestedinside, be outside, or a sibling of the passed in element.
Whitespace is normalized. Using multiple ids will
join the referenced elements’ text content separated by a space.
When a
stringargument is passed through, it will perform a wholecase-sensitive match to the error message text.
To perform a case-insensitive match, you can use a
RegExpwith the/imodifier.
To perform a partial match, you can pass a
RegExpor useexpect.stringContaining("partial string").Examples