Manipulating State of Stateful Component in Tests

Let’s learn how to manipulate states of a stateful component through Enzyme's method in tests.

We'll cover the following

Manipulating state in tests

So far, the carousel is just a pair of buttons. What it really needs is some slides. A simple approach to this is to give the Carousel instance an array of data as a prop called slides, then pass the data from slides[slideIndex] as props to a CarouselSlide.

  • Replace the existing beforeEach block to set the slides prop on the Carousel instance, then add a (failing) test for the slide-passing behavior:

Get hands-on with 1200+ tech skills courses.