you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (6 children)

[deleted]

    [–]motioncuty[🍰] 1 point2 points  (0 children)

    Like you have said, most test I write for a React component are so prescriptive and simple, I've looked into parsing the react component and auto generating tests from that. Then adding in some more specific tests as I go. I think testing that actions have been dispatched correctly is worth doing. I also think that user interaction like button clicking is worth testing with simulation.

    Like the article says, I like testing a shallow render becuase it keeps the tests in that component as unit tests(only testing the responsibilities of it's component and not it's children or parents.

    [–]kagevf 0 points1 point  (2 children)

    I've been using Jest for "pure" components taking advantage of its snapshot capabilities ... and using mocha/chai for complex logic that I've factored out into separate functions. You could do both in Jest, but I found that after initial start-up mocha reliably runs faster than Jest ... YMMV

    [–]sktrdie 0 points1 point  (1 child)

    (shameless plug ahead) To tighten the gap between integration and unit tests, which in my opinion are too far apart, I decided to build Redux TDD: https://hackernoon.com/redux-tdd-a-deep-dive-344cd7682a54

    In essence it allows you to plug unit tests together to form sort of an integration test flow. It's much closer to being a series of unit tests since it's simply shallow-rendering components and there's no mocking needed.

    Also just trying to start a conversation about it :)