Unit test cases for Angular using angular-plotly

I’m trying to write unit test cases in Angular where I’m using plotly-plot.
It gives error of plotly-plot not being a known element for the component, so I added PlotlyModule in the imports array.

This I created in the component.spec.ts also, if I don’t do this, it gives error of PlotlyJs object is not imported correctly.

import * as PlotlyJS from 'plotly.js-dist-min';
import { PlotlyModule } from 'angular-plotly.js';

PlotlyModule.plotlyjs = PlotlyJS;

Then I added the module in the Testbed configuration


Now this throws an error component threw errors during cleanup. But there is no subscription inside the component.

What I’m doing wrong here? How do we import the Plotly for the test cases?
Any help would be appreciated.

Whoever finds the same issue in future, just add CUSTOM_ELEMENT_SCHEMA to your imports array in the test file.

I am also trying to write the unit test for Plolty.newPlot() method but I am unable to figure it out.