TypeError: (0 , _component.default) is not a function mock tests
See original GitHub issue💬 Questions and Help
Hi,
We are using the loadable/component function to load components but are having issues with the mocking tests and running into the following error:
TypeError: (0 , _component.default) is not a function
Within our test we have just created a mock like so
jest.mock('@loadable/component', () => ({
loadable: jest.fn()
}));
Also tried
jest.mock('@loadable/component', () => {
const original = jest.requireActual('@loadable/component');
return {
...original,
__esModule: true,
default: () => {},
loadableReady: callback => callback(),
};
});
But this still errors.
Any ideas on how we can mock it?
Issue Analytics
- State:
- Created 2 years ago
- Comments:15
Top Results From Across the Web
Jest failing with TypeError: (0 , _user.default) is not a function
I've tried mocking the getUserInfo() other ways and it still fails. What is wrong here? I'm thinking it has something to do with...
Read more >Jest failing with TypeError: (0 , _user.default) is not a function ...
I had this same problem and I solved it doing: jest.mock('../src/services/user', () => ({ __esModule: true, default: () => Promise.resolve({ ...
Read more >Bypassing module mocks - Jest
Jest allows you to mock out whole modules in your tests, ... throwing the error: TypeError: response.text is not a function .
Read more >Unit tests - Mattermost Developers
If you get an error like UnhandledPromiseRejectionWarning: TypeError: (0 , \_fff.hhh) is not a function. Check if you're mocking part of an imported...
Read more >(0 , dayjs_1.default) is not a function - You.com - You.com
max method existed, but the test suite only imported the component and not its parent, therefore the plugin wasn't being applied to dayjs....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@tejpowar how did you mock the loadable import?
Did anyone found any solution?