Closed WillCoScofield closed 4 months ago
Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson
Hi Plotly Team,
I am using Plotly on Angular 9 in order to create some data vizs, but running into an issue when using Jest to test a component (very basic unit test) that imports the Plotly.js library to be used like so:
The child (thumbnail service) and parent (dashboard) components that directly and indirectly call Plotly when testing, throw: ● Test suite failed to run
and,
● Test suite failed to run
We imported Plotly as import * as Plotly from 'plotly.js' and used the angular.json script setup for accessing the package (which works for giving us access to the Plotly Obj and methods on the thumbnail service):
"scripts": [ "node_modules/plotly.js/dist/plotly.min.js" ]
We tried installing jest-canvas-mock, following this thread thread We tried jest fn mocking the service that imports the Plotly package. We tried mocking both getContext and createObjectURL in our setupJest.ts file with empty returns:
We included the angular-jest-preset astTransformers and other mentions found here: Stack Overflow failed to load component html issue Here are other potentially relevant files: tsconfig.ts:
jest.config.ts:
package.json:
thumbnail.service.ts:
thumbnail.service.spec: