react-plotly.js
react-plotly.js copied to clipboard
testing with create-react-app
Hi! Thanks for all the good work.
I am trying to make the simple test that comes with create-react-app to work. (Which checks whole app renders without a crash)
I get an error like below.
TypeError: Cannot read property 'document' of undefined
at node_modules/plotly.js/dist/plotly.js:74:22
at node_modules/plotly.js/dist/plotly.js:9620:2
at Object.<anonymous>._$numerical_517.BADNUM (node_modules/plotly.js/dist/plotly.js:7:88)
at Object.<anonymous> (node_modules/plotly.js/dist/plotly.js:7:327)
at Object.<anonymous> (node_modules/react-plotly.js/react-plotly.js:11:15)
at Object.<anonymous> (src/components/Graph/StyledGraph.js:2:20)
at Object.<anonymous> (src/components/Graph/index.js:4:20)
at Object.<anonymous> (src/container/GraphContainer.js:6:14)
at Object.<anonymous> (src/App.js:7:23)
at Object.<anonymous> (src/Main.js:14:12)
at Object.<anonymous> (src/App.test.js:5:13)
I am using pretty much the default command that comes with create-react-app
. (Test command node scripts/test.js --env=jsdom
, react-app-preset
)
import Plotly from 'plotly.js/dist/basic';
I am using Plotly like below.
import Plotly from 'plotly.js/dist/basic';
import createPlotlyComponent from 'react-plotly.js/factory';
const Plot = createPlotlyComponent(Plotly);
I have exactly the same error. Is there already a solution for this?
I encountered a similar undefined
issue (but not exactly) went away when I included 'jest-canvas-mock'
I was using the react testing library (NOT enzyme)
here:
- https://github.com/mithi/hexapod/commit/f55dc3d49393c76787f2148bd2f3521c6c79ff7d
But I encountered a different issue which is
Error while plotting: RangeError: Maximum call stack size exceeded
https://github.com/plotly/react-plotly.js/issues/186