My name is Kent C. Dodds and I'm a Remix Co-Founder, JavaScript engineer, and teacher. I'm also active in the open source community. I like my family, JavaScript, and React.
You can get rid of the loader test ID by using getByText(/loading/i). And if it's a spinner instead, then you can use aria-label="loading" and getByLabel(/loading/i)
My name is Kent C. Dodds and I'm a Remix Co-Founder, JavaScript engineer, and teacher. I'm also active in the open source community. I like my family, JavaScript, and React.
My name is Kent C. Dodds and I'm a Remix Co-Founder, JavaScript engineer, and teacher. I'm also active in the open source community. I like my family, JavaScript, and React.
Jest will auto-update that code to have an inline snapshot for you and you'll get a tiny bit more confidence that it's rendering what it should (without the implementation details of how that text appears on the screen).
Sweet!
You can get rid of the
loader
test ID by usinggetByText(/loading/i)
. And if it's a spinner instead, then you can usearia-label="loading"
andgetByLabel(/loading/i)
Yes that will make it more accessible as well! Thanks a lot :)
Oh, also, you can improve this as well:
Change that to this:
And finally, you may like to do this for your assertion:
Jest will auto-update that code to have an inline snapshot for you and you'll get a tiny bit more confidence that it's rendering what it should (without the implementation details of how that text appears on the screen).
Inline snapshots are great! That's one new arsenal in my tooklit.