title: how to loop to expect a list of item in jest
body: <p>I have added the below jest unit test to render a component and I am expecting some of its elements using &quot;getAllByText&quot; as there are multiple similar elements. I got a review comment to loop over the list of element if there are more than 1 and expect each of them to be visible. Can someone please help me in modifying the test to loop over all the elements.</p>
  <pre><code>it('should render seat total wrapper on small breakpoint', () =&gt; {
      render(
        &lt;MockViewportProvider viewSize={ViewSizes.SMALL}&gt;
          &lt;SeatMapContext.Provider value={{ state: contextObj, dispatch: noop }}&gt;
            &lt;SeatMapCabinAndSeatWrapper
              flightSeatMapPlaneData={seatMapPlanesData}
              flightLegsDetails={FlightLegsDetails}
              onChangeLegIndex={jest.fn}
              selectedLegIndex={0}
              handleLegendButtonClick={jest.fn()}
              handleApplySeatSelection={handleApplySeatSelection}
            /&gt;
          &lt;/SeatMapContext.Provider&gt;
        &lt;/MockViewportProvider&gt;
      );
      expect(screen.getByRole('button', { name: 'Next Flight' })).toBeVisible();
      expect(screen.getAllByText('$276.24')[0]).toBeVisible();
    });
  </code></pre>
  <p>Review comments -&gt; &quot;if there are expected to be more than 1 item then please loop over the list and expect each element to be visible
  if there should only be 1 item then please determine how to use getByText&quot;.</p>