-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conform toHaveErrorMessage
to Spec and Rename to toHaveAccessibleErrorMessage
#503
Conform toHaveErrorMessage
to Spec and Rename to toHaveAccessibleErrorMessage
#503
Conversation
So I actually don't know where the type definitions are. 😳 Some assistance would be helpful. 😅 Is the documentation automatically generated from the type definitions/JSDocs? Edit: I'm assuming that the docs and the type definitions are separate -- interestingly enough. Feel free to correct me if I'm wrong. But if this is indeed the case, then I'll update the docs here and then update the types in Definitely Typed. Is there a plan for this library to own its types in the future? |
4b54098
to
e04f4f7
Compare
e04f4f7
to
ea25301
Compare
Created in response to (and thus depends on): - testing-library/jest-dom#503
Included Changes: - According to the WAI-ARIA spec, passing an invalid `id` to `aria-errormessage` now fails assertion. This means that any empty spaces inside `aria-errormessage` will now cause test failures. - According to the WAI-ARIA spec, developers can now assert that an accessible error message is missing if `aria-invalid` is `false` (or if the `aria-errormessage` attribute is invalid). - Updated the error message and test cases surrounding the requirement for `aria-invalid`. They are now more detailed/accurate. - Renamed `toHaveErrorMessage` to `toHaveAccessibleErrorMessage` to be consistent with the other a11y-related methods (`toHaveAccessibleName` and `toHaveAccessibleDescription`). - Note: This deprecates the previous `toHaveErrorMessage` method. - Updated documentation. Similar to the `toHaveAccessibleDescription` method, this description is much more lean, as the reader can simply read the WAI ARIA spec for additional details/requirements.
This makes the code easier to maintain as more exports are added.
ea25301
to
fbe6feb
Compare
Codecov Report
@@ Coverage Diff @@
## main #503 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 26 27 +1
Lines 630 664 +34
Branches 236 251 +15
=========================================
+ Hits 630 664 +34
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
🎉 This PR is included in version 5.17.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Created in response to (and thus depends on): - testing-library/jest-dom#503
…rary/jest-dom` Types by @ITenthusiasm Created in response to (and thus depends on): - testing-library/jest-dom#503
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) | dependencies | minor | [`5.16.4` -> `5.17.0`](https://renovatebot.com/diffs/npm/@testing-library%2fjest-dom/5.16.4/5.17.0) | --- ### Release Notes <details> <summary>testing-library/jest-dom (@​testing-library/jest-dom)</summary> ### [`v5.17.0`](https://github.com/testing-library/jest-dom/releases/tag/v5.17.0) [Compare Source](testing-library/jest-dom@v5.16.5...v5.17.0) ##### Features - New `toHaveAccessibleErrorMessage` better implementing the spec, deprecate `toHaveErrorMessage` ([#​503](testing-library/jest-dom#503)) ([d717c66](testing-library/jest-dom@d717c66)) ### [`v5.16.5`](https://github.com/testing-library/jest-dom/releases/tag/v5.16.5) [Compare Source](testing-library/jest-dom@v5.16.4...v5.16.5) ##### Bug Fixes - migrate ccs v3 to [@​adobe/css-tools](https://github.com/adobe/css-tools) v4 ([#​470](testing-library/jest-dom#470)) ([948d90f](testing-library/jest-dom@948d90f)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4xNDIuNSIsInVwZGF0ZWRJblZlciI6IjM4LjE0Mi41IiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=--> Reviewed-on: https://gitea.bruyant.xyz/alexandre/PaletteSwitcher/pulls/45 Co-authored-by: Renovate <[email protected]> Co-committed-by: Renovate <[email protected]>
What
Primarily, this PR is intended to be a fix that conforms the original
toHaveErrorMessage
method more closely to the WAI ARIA spec. This PR also renamestoHaveErrorMessage
totoHaveAccessibleErrorMessage
.There was also a slight change to how the assertions are exported from
matchers.js
.Why
Spec Concerns:
Currently, there are some ways in which
toHaveErrorMessage
doesn't conform to the specifications:aria-errormessage
is expected to be a singleid
, not a list ofid
s. Supplying multipleid
s is illegal (because it would constitute an invalid singularid
). I didn't recognize this until reading through the spec more closely.Rename:
The other a11y-related methods explicitly call out the fact that they're intended for accessibility-related assertions. I figured it would be helpful to keep things consistent.
Exports Update:
This is completely optional. But since it was simple, I thought it was worth trying and running by the maintainers. The new approach involves less lines of code, which will hopefully be more readable and less prone to error when it's updated.
How
These changes were implemented with a new
toHaveAccessibleErrorMessage
method that largely built on top of the previoustoHaveErrorMessage
method. I tested thearia-errormessage
attribute with my iPhone to make sure the test cases that I wrote were consistent with reality.Technically speaking, it's debatable whether or not the
toHaveAccessibleErrorMessage
assertion should have early error cases that guide the user to success with intermediate checks (e.g., checks onaria-errormessage
andaria-invalid
). But since thearia-errormessage
attribute is a little more complicated than the others, it could be helpful to keep the checks/warnings around. I'm not tied to down to either view, but I continued with the pattern that was already established (i.e., the pattern of helping the developer correctly give an error message to an element).Checklist
I forgot the typedefs and docs. 😭 I'll look into this. Feel free to add any comments in the meantime.Resolves #256
Improves #370