Jest Test ToHaveBeenCalledWith returns JSX

Viewed 19

When testing a specific pattern I'm calling .toHaveBeenCalledWith and it returns a JSX element. However I am unsure how to test that it is returning the proper JSX. Is there a way to test the contents of a JSX in this manner?

expect(store.setPattern).toHaveBeenCalledWith(expect.objectContaining({
   stepOne: expect.objectContaining({
      res: myJSX, //not sure what to put here to find that it includes red v blue
   }),
});

And then myJSX would have something that I'd want to find. For instance it includes blue vs red.

<div>
   <p>This car is red</P>
</div>
0 Answers
Related