PLAY PODCASTS
Tests for accessible error messages
Season 2 · Episode 24

Tests for accessible error messages

Jan asked this on 2022-07-25

The Call Kent Podcast

July 26, 20223m 39s

Audio is streamed directly from the publisher (media.transistor.fm) as published in their RSS feed. Play Podcasts does not host this file. Rights-holders can request removal through the copyright & takedown page.

Show Notes

Hi Kent!

My name is Jan. I'd like to ask you: How do you write tests for accessible error messages with testing library?

By accessible error messages, I mean, suppose you have a form with an input. You have a p tag which renders the error, if there is an error. And that p tag has an id.

And now you pass this p tags id to the input as a value for the aria-describedby property.

So far, I'm using byText to check for the existence of that error in my tests, but I was wondering whether there is a better query for that?

Thank you!

 Tests for accessible error messages

Topics

testing-libraryaccessibilityaccessible errorsforminputerrorerror message