Closed astorije closed 2 years ago
We use AOM aria properties within the components. Are you using Jest or JSDom? It could be they don't support AOM
We're using Jest and JSDom by way of React Testing Library. Was AOM being used before v5.6.1? Everything worked fine in v5.6.0 and tests started failing as of v5.6.1 only.
URL above has an GitHub rendering issue, but I suspected this change caused this:
We have been working on moving away from overriding properties on the native HTMLElement prototype since it can cause unexpected behaviors in some browsers as well as performance issues. Some web component tools actively try to prevent this https://github.com/ionic-team/stencil/blob/main/src/compiler/transformers/reserved-public-members.ts
Good to know, thank you! Any recommendations you could provide us on how to move forward here? We're kinda stuck between a rock and a hard place on that one as well. If all else fails, we can mock the components as a last resort, though we try to avoid this as much as we can.
I filed an issue again jsdom to support the AOM properties: https://github.com/jsdom/jsdom/issues/3323
We have a polyfill that will fall back to setAttribute
for browsers that don't support the property (currently just Firefox), but it doesn't run in node because there were issues with jsdom.
Hi there 👋, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed issues after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.
Describe the bug
ARIA roles and attributes are missing in Clarity Core v5.6.1, failing our React Testing Library tests that use
await screen.findByRole('button')
.How to reproduce
Steps to reproduce the behavior:
yarn install
)yarn test
on themain
branch and see the error in the console outputcore-5.6.0
branch, install dependencies again (yarn install
), and runyarn test
to see the same tests passHere is the error output on v5.6.1:
As you can tell, the
cds-button
element is missing therole
attribute (and thearia-disabled
one). I suspect the issue originated at https://github.com/vmware/clarity/compare/v5.6.0...v5.6.1#diff-40c8e7c2cb3e2e864efc9529dbba5def804aa9131b0ab70c82fb87cfc86aba00 (warning: GitHub's renderer currently removes the # betweenv5.6.1
anddiff
in this URL 🤷♂️)Expected behavior
The
core-5.6.0
contains the expected behavior. When running tests, we get:Versions
Clarity project:
Clarity version:
Framework:
Additional notes
To be noted that the role does appear fine in the browser but not in the test DOM, not sure what kind of magic is happening there: