0
votes

I have a React container-pattern component with some complex logic which manipulates its internal state via this.setState(), etc. I'd like to test both the methods attached to the component which manipulate this state, and the value of this.state before and after they run. I've been poring over the Jest docs and while I see lots of examples of e.g. snapshotting, I specifically need to test this container in the abstract, apart from its display/rendering.

What do folks recommend? What have I missed? :)

1

1 Answers

3
votes

Jest is a test runner, mocking framework and has snapshot testing. Snapshot testing tests only the final render.

To test state, I recommend using Jest along with Enzyme. Enzyme allows to simulate actions, inspect state, etc.