React testing exercise Testing ProductImage Gallery

Why I’m getting the following error message.

Scroll up the error code there should be a message above that

here is the rest of the error.

Well i can think of a couple reason, but you’ll have to debug. It’d help to see what img elements your working with.

1.You should check the format of images your receiving to make sure the have the expected properties.

  1. If your receiving images via api or get call that you run it as async and await the promise or put a time function to wait to get the data before you try to use said data.

Hi, as I stated before, this is a chapter exercise from React-testing not something I am doing it on my own and I followed everything as per the instruction but still it’s not working. As you know getByRole will get a single element but when you do query using getAll then it will check for all to get the similar lements but here it’s throwing some error from testing library but not sure.

Anyhow I will check the component also once.

I found the exact issue. The issue is, I added alt=“” attribute which is not added in test case after removing alt in components fixed the problem.

1 Like