I am writing test cases for a component and currently using MonacoEditor in my component. During running test cases I was getting below error:
Cannot find module 'monaco-editor' from 'node_modules/@uiw/react-monacoeditor/lib/index.js'
To Fix this above error I added a moduleNameMapper property inside package.json
"moduleNameMapper": {
"monaco-editor": "<rootDir>/node_modules/@uiw/react-monacoeditor/lib/index"
}
and after adding the property inside package.json and ran test case again I got the following error somewhere inside monacoEditor node_modules config files.
Error: Uncaught [TypeError: Cannot read properties of undefined (reading 'create')]
I am looking for some workaround so I can completely mock this MonacoEditor module with jest and react testing library (RTL) or any way to resolve the error I am getting currently
Tried to mock like below and tried numerous ways provided online but nothing worked.
jest.mock('@uiw/react-monacoeditor', ()=>({
MonacoEditor: ()=>null
}));
Error I am getting now:
Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
Thanks in advance