Yoctol / react-d3-cloud

A word cloud react component built with d3-cloud.
https://yoctol.github.io/react-d3-cloud
MIT License
142 stars 47 forks source link

TypeError running tests. #92

Closed reinaldoviera1 closed 6 years ago

reinaldoviera1 commented 7 years ago

When I run tests using the react-d3-cloud I'm getting this: `TypeError: Cannot read property 'getImageData' of null

  at getContext (node_modules/d3-cloud/index.js:90:50)
  at Object.cloud.start (node_modules/d3-cloud/index.js:33:27)
  at WordCloud.render (node_modules/react-d3-cloud/lib/WordCloud.js:85:14)
  at node_modules/react-test-renderer/lib/ReactCompositeComponent.js:795:21
  at measureLifeCyclePerf (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:75:12)
  at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:794:25)
  at ReactCompositeComponentWrapper._renderValidatedComponent (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:821:32)
  at ReactCompositeComponentWrapper.performInitialMount (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:361:30)
  at ReactCompositeComponentWrapper.mountComponent (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:257:21)
  at Object.mountComponent (node_modules/react-test-renderer/lib/ReactReconciler.js:45:35)
  at ReactCompositeComponentWrapper.performInitialMount (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:370:34)
  at ReactCompositeComponentWrapper.mountComponent (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:257:21)
  at Object.mountComponent (node_modules/react-test-renderer/lib/ReactReconciler.js:45:35)
  at ReactCompositeComponentWrapper.performInitialMount (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:370:34)
  at ReactCompositeComponentWrapper.mountComponent (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:257:21)
  at Object.mountComponent (node_modules/react-test-renderer/lib/ReactReconciler.js:45:35)
  at ReactTestComponent.mountChildren (node_modules/react-test-renderer/lib/ReactMultiChild.js:236:44)
  at ReactTestComponent.mountComponent (node_modules/react-test-renderer/lib/ReactTestRenderer.js:62:10)
  at Object.mountComponent (node_modules/react-test-renderer/lib/ReactReconciler.js:45:35)
  at ReactTestComponent.mountChildren (node_modules/react-test-renderer/lib/ReactMultiChild.js:236:44)
  at ReactTestComponent.mountComponent (node_modules/react-test-renderer/lib/ReactTestRenderer.js:62:10)
  at Object.mountComponent (node_modules/react-test-renderer/lib/ReactReconciler.js:45:35)
  at ReactTestComponent.mountChildren (node_modules/react-test-renderer/lib/ReactMultiChild.js:236:44)
  at ReactTestComponent.mountComponent (node_modules/react-test-renderer/lib/ReactTestRenderer.js:62:10)
  at Object.mountComponent (node_modules/react-test-renderer/lib/ReactReconciler.js:45:35)
  at ReactTestComponent.mountChildren (node_modules/react-test-renderer/lib/ReactMultiChild.js:236:44)
  at ReactTestComponent.mountComponent (node_modules/react-test-renderer/lib/ReactTestRenderer.js:62:10)
  at Object.mountComponent (node_modules/react-test-renderer/lib/ReactReconciler.js:45:35)
  at ReactCompositeComponentWrapper.performInitialMount (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:370:34)
  at ReactCompositeComponentWrapper.mountComponent (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:257:21)
  at Object.mountComponent (node_modules/react-test-renderer/lib/ReactReconciler.js:45:35)
  at ReactTestComponent.mountChildren (node_modules/react-test-renderer/lib/ReactMultiChild.js:236:44)
  at ReactTestComponent.mountComponent (node_modules/react-test-renderer/lib/ReactTestRenderer.js:62:10)
  at Object.mountComponent (node_modules/react-test-renderer/lib/ReactReconciler.js:45:35)
  at ReactCompositeComponentWrapper.performInitialMount (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:370:34)
  at ReactCompositeComponentWrapper.mountComponent (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:257:21)
  at Object.mountComponent (node_modules/react-test-renderer/lib/ReactReconciler.js:45:35)
  at ReactCompositeComponentWrapper.performInitialMount (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:370:34)
  at ReactCompositeComponentWrapper.mountComponent (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:257:21)
  at Object.mountComponent (node_modules/react-test-renderer/lib/ReactReconciler.js:45:35)
  at mountComponentIntoNode (node_modules/react-test-renderer/lib/ReactTestMount.js:55:31)
  at ReactTestReconcileTransaction.perform (node_modules/react-test-renderer/lib/Transaction.js:143:20)
  at batchedMountComponentIntoNode (node_modules/react-test-renderer/lib/ReactTestMount.js:69:27)
  at ReactDefaultBatchingStrategyTransaction.perform (node_modules/react-test-renderer/lib/Transaction.js:143:20)
  at Object.batchedUpdates (node_modules/react-test-renderer/lib/ReactDefaultBatchingStrategy.js:62:26)
  at Object.batchedUpdates (node_modules/react-test-renderer/lib/ReactUpdates.js:97:27)
  at Object.render (node_modules/react-test-renderer/lib/ReactTestMount.js:128:18)
  at Object.<anonymous> (app/tests/ui/reactjs/extras/Stat.test.js:98:51)
  at Promise.resolve.then.el (node_modules/p-map/index.js:42:16)

` I alredy did the pre-install and I'm getting the same error. I even ran the tests given in the code(src/test) and It gave me the same issue I use jest with the same sintaxis to do tests in my app.

chentsulin commented 6 years ago

https://github.com/jasondavies/d3-cloud/blob/4fc1a943d01d270e7838c97bb8ee48ca15da20be/index.js#L32-L33

There should be some issue on canvas creation, please check out node-canvas Installation guides and try again. https://github.com/Automattic/node-canvas/wiki