Accessibility · Senior · Question 65 of 75
Which test assertion checks what a user of assistive tech gets?
- 1
expect(button.innerHTML).toContain("<svg") - 2
expect(button).toHaveAttribute("class", "btn") - 3
expect(button).toHaveAccessibleName("Save")
Show the answer
Correct answer: expect(button).toHaveAccessibleName("Save")
Explanation
jest-dom computes names and descriptions as the browser would. Attribute checks test implementation details instead.