Illustration of a microphone

Calls with Kent C. Dodds.

You call, I'll answer.

Listen to the podcasts here
Phone sitting on a stool

What's this all about?

The goal of the Call Kent Podcast is to get my answers to your questions. You record your brief question (120 seconds or less) right from your browser. Then I listen to it later and give my response, and through the magic of technology (ffmpeg), our question and answer are stitched together and published to the podcast feed.

I look forward to hearing from you!

Record your call

Calls with Kent C. Dodds — 83 episodes

74. Tests for accessible error messages
03:39
Keywords

testing-library, accessibility, accessible

Tweet this
Description

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

Looking for more content?

Have a look at these articles.

See the full blog