Skip to content
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

Update @types/testing-library__jest-dom dependency #484

Closed
robinmetral opened this issue Oct 17, 2022 · 1 comment · Fixed by #511
Closed

Update @types/testing-library__jest-dom dependency #484

robinmetral opened this issue Oct 17, 2022 · 1 comment · Fixed by #511
Labels

Comments

@robinmetral
Copy link

robinmetral commented Oct 17, 2022

  • @testing-library/jest-dom version: ^5.16.5
  • node version: 16
  • npm (or yarn) version: yarn 2 latest

Relevant code or config:

An example of when this is an issue: (see below for the root cause)

it('should have an accessible name', () => {
  const { getByRole } = render(<input type="checkbox" aria-label="label" />);
  const inputEl = getByRole('checkbox');

  expect(inputEl).toHaveAccessibleName('label'); // ❌ toHaveAccessibleName does not exist (TS and eslint errors)
});

What you did:

I'm asserting that components must have accessible names/descriptions.

What happened:

There's a TypeScript error warning that toHaveAccessibleName does not exist in the Jest global matchers.

Reproduction:

I don't think it's necessary in this case. Let me know if you'd like it.

Problem description:

The issue is with the @types dependency that @testing-library/jest-dom includes:

"@types/testing-library__jest-dom": "^5.9.1",

This is an outdated version (the latest is 5.14.5 from 4 months ago) which doesn't yet declare matchers such as toHaveAccessibleName.

Suggested solution:

  • update the dependency 🙂
  • even better (?): include types as part of @testing-library/jest-dom. I've seen this suggested in several issues, but haven't dug into what the blockers would be. But including types as part of this package would prevent this kind of issues from happening in the future
  • (short-term fix for people running into the issue: install the latest version of @types/testing-library__jest-dom in your project)
kodiakhq bot pushed a commit to sumup-oss/circuit-ui that referenced this issue Oct 19, 2022
…#1795)

* Format some component prop descriptions

* Remove live region from ImageInput FieldValidationHint

A live region only makes sense when the validationHint is an error, not a description. Further research and design are required to improve the field-level validation pattern. Removing the live region and will reintroduce in the future when consistent with other form components.

* Move validationHint in aria-describedby in Input, Select and RadioButtonGroup

* Fix TextArea UI bug

* Add changeset

* Update snapshots

* Reintroduce ImageInput live region

* Connect validationHint to cherckbox using aria-describedby

* Add live regions to validation hints when they are status messages

* Update snapshots

* Fix changeset again

Co-authored-by: Connor Bär <connor-baer@users.noreply.github.com>

* Install jest-dom types to get definitions for latest matchers

See testing-library/jest-dom#484

* Add explicit role to live region

This makes it compatible with RTL (we can use getByRole('status') and is generally more explicit and perhaps more compatible (not tested)

* Add accessibility tests to Checkbox component

* Add accessibility tests to the ImageInput component

* Update test utils and improve test grouping in Input, RadioButtonGroup and Select specs

* Add accessibility tests to the Input spec

* Add accessibility tests to the Select spec

* Add accessibility tests to the RadioButtonGroup spec

* Add patch changesets

* Rephrase changeset

Co-authored-by: Connor Bär <connor-baer@users.noreply.github.com>

Co-authored-by: Connor Bär <connor-baer@users.noreply.github.com>
@github-actions
Copy link

🎉 This issue has been resolved in version 6.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant