Lottie mocking is not working in react-testing-library

Viewed 385

When I tried to run test cases I am getting the following error:

TypeError: Cannot set property 'fillStyle' of null
for line: import Lottie from 'react-lottie';

Can someone please help how to mock this library? I have also added 'jest-canvas-mock' library and added the below configuration in the jest.config.ts:

import type { Config } from '@jest/types';

// Sync object
const config: Config.InitialOptions = {
  verbose: true,
  setupFiles: ['jest-canvas-mock']
};
export default config;

Versions of the packages used:

react: 17.0.2
react-testing-library: 11.2.7
react-lottie: 1.2.3
0 Answers
Related