:זה בהדיקה שלי
import React from ‘react’;
import { render } from ‘@testing-library/react’;
import BaseGraph from ‘./BaseGraph’;
describe(‘BaseGraph Component’, () => {
let originalWindow:any;
beforeAll(() => {
originalWindow = { …window };
Object.defineProperty(window, ‘crypto’, {
value: {
getRandomValues: () => new Uint32Array(10) // Mocking getRandomValues for crypto object
}
});
});
it(‘should render without crashing’, () => {
render(<BaseGraph animationEnabled={true} theme=”light1″ text=”adfsgf” type=”column” dataPoints={[
{ x: 10, y: 71 },
{ x: 20, y: 55 },
{ x: 30, y: 50 },
{ x: 40, y: 65 },
{ x: 50, y: 71 },
{ x: 60, y: 68 },
{ x: 70, y: 38 },
{ x: 80, y: 92 },
{ x: 90, y: 54 },
{ x: 100, y: 60, indexLabel: ‘high!’ },
{ x: 110, y: 21 },
{ x: 120, y: 49 },
{ x: 130, y: 36 },
]}/>);
});
});
ואני מקבלץ שגיאה כזו:
TypeError: Cannot read properties of null (reading ‘webkitBackingStorePixelRatio’)
❯ Na node_modules/@canvasjs/charts/canvasjs.min.js:36:25
❯ va node_modules/@canvasjs/charts/canvasjs.min.js:39:26
❯ new m node_modules/@canvasjs/charts/canvasjs.min.js:138:458
❯ CanvasJSChart.componentDidMount node_modules/@canvasjs/react-charts/canvasjs.react.js:33:16
31| componentDidMount() {
32| //Create Chart and Render
33| this.chart = new CanvasJS.Chart(this.containerRef.current, this.options);
| ^
איך אפשר לטפל בזה?