1

I'm looking to do unit testing with react.js, d3 and mocha/chai. In order to integrate d3 with react.js, a lot of the d3 is done in componentDidMount since d3 cannot play very nicely with React's virtual DOM (similar to this http://nicolashery.com/integrating-d3js-visualizations-in-a-react-app/).

My question is how do I test the d3 functions? Is there a clean way I can wait for componentDidMount to complete before checking if the chart exists, etc.

Thanks!

Dennis
  • 21
  • 6

1 Answers1

1

The simple answer is using React.renderComponent's callback.

React.renderComponent(Component(), node, onMountCallback);
Brigand
  • 84,529
  • 20
  • 165
  • 173