'TypeError: Cannot read property 'type' of undefined Jest react testing [closed]

I am using jest and enzyme to test the app components written using material UI library. Then in one of my package I got this error Click here to see the error



Solution 1:[1]

I solved the above problem by following the below steps

1.create a folder and add the below code inside setupFilesAfterEnv.js

jest.mock('@material-ui/core/styles/colorManipulator', () => ({

  fade: jest.fn(),

}));

2.import the path of the above file in jest.config.js which is in your package folder

 setupFilesAfterEnv: [require.resolve('../../test/setupEnzymeAdapter.js'),
<rootDir>../tests/setupFilesAfterEnv.js

My issue got fixed with this.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BALAJI