It looks like when testing accessibility in a jest unit test using the Radix Primitive Radio Group by firing userEvents from the @testing-library/user-event package. The test results vary from real live interactions with the radio group. As you can see from the test example below when using RadioGroup and using the arrow keys the test fail toBeChecked. However, the same test with an html radio input passes that same check.
Current Behavior
This test will fail on the last expect because the second option isn't checked marked as checked nor is onValueChange being called:
Received element is not checked:
<button aria-checked="false" class="RadioGroupItem" data-radix-collection-item="" data-state="unchecked" id="r2" role="radio" tabindex="0" type="button" value="comfortable" />
Expected behavior
I would expect this test of accessibility to pass when using radix primitive radio group. I ran the same test with a normal html input radio and tests pass so it seems to point to an issue with Radix Primitive Radio Group and not jest or userEvent:
This example should open and stat a Run Tests tab in the terminal where you can see the failing test using Radix as well as the passing test using normal radio inputs. If that tab doesn't open you can go to the terminal tab on the left side and click Run tests under the tasks section.
Bug report
It looks like when testing accessibility in a jest unit test using the Radix Primitive Radio Group by firing userEvents from the
@testing-library/user-event
package. The test results vary from real live interactions with the radio group. As you can see from the test example below when using RadioGroup and using the arrow keys the test failtoBeChecked
. However, the same test with an html radio input passes that same check.Current Behavior
This test will fail on the last expect because the second option isn't checked marked as checked nor is onValueChange being called:
test output:
Expected behavior
I would expect this test of accessibility to pass when using radix primitive radio group. I ran the same test with a normal html input radio and tests pass so it seems to point to an issue with Radix Primitive Radio Group and not jest or userEvent:
Reproducible example
CodeSandbox Devbox Example
This example should open and stat a
Run Tests
tab in the terminal where you can see the failing test using Radix as well as the passing test using normal radio inputs. If that tab doesn't open you can go to the terminal tab on the left side and clickRun tests
under the tasks section.Your environment
Dev Box given by CodeSandbox