Reputation: 2109
How do you unit test (with jest
and enzyme
) a functional component that uses the useReactiveVar
hook?
Should I mock the useReactiveVar
hook with jest
?
Upvotes: 7
Views: 3037
Reputation: 106
you can mock whole apollo client in each test to give different responses. I mean:
jest.mock('@apollo/client', () => ({
makeVar: () => {
return {};
},
useReactiveVar: () => {
return { account: { name: 'Test' } };
},
}));
But this is helpful only when testing component that use only one reactiveVar at all.
Upvotes: 5