Theo's Typesafe CultTTC
Theo's Typesafe Cult2y ago
34 replies
beroer

testing question: TypeError: undefined is not a function

Does anyone know how to solve this error? I don't understand this error message at all. Why is the error thrown on the render line? The props are clearly defined on line 18 and 19.
    ColorCarouselImages
      ✕ renders all images into the document & all have correct src attribute (350 ms)

  ● Client: ColorCarousel › ColorCarouselImages › renders all images into the document & all have correct src attribute

    TypeError: undefined is not a function
        at Array.map (<anonymous>)

      18 |       const gender = "kids"
      19 |       const images = ['blue.jpg', 'green.jpg', 'purple.jpg', 'red.jpg', 'yellow.jpg', 'pink.jpg', 'black.jpg', 'white.jpg']
> 20 |       render(<ColorCarouselImages gender={gender} images={images} />)
         |             ^
      21 |
      22 |       const onScreenImages = await screen.findAllByRole('img')

i also tried getAllBy() and without async but same error.
I'm using the shadcn carousel in the component I'm testing, could that have messed the test up? the carousel was done manually before resorting to shadcn, where i didn't have any problems with the tests.
Was this page helpful?