Mock a function or setState using jest in ReactJS.

lets assume that we need to mock setStatus(). So, in test file we will mock by using jest as follows.

Displaying comma separated elements using map function from Array of Objects – ReactJS

lets take an example of the following Array

lets use map function to display names of class-5 in the same row.

if we use .toString() to the map function, comma separated names will display.