I'd like to test a react component, which displays a list of element or not, based on the return value of a custom hook.
In my first test, I want to make sure nothing is displayed, so I used this at the top of my test method:
jest.mock('components/section/hooks/use-sections-overview', () => {
return {
useSectionsOverview: () => ({
sections: [],
}),
};
});
in the second test, I want to display something, so I used this one
jest.mock('components/section/hooks/use-sections-overview', () => {
return {
useSectionsOverview: () => ({
sections: [
{id: '1', content: 'test'}
],
}),
};
});
Unfortunately, when running my test, it always returns an empty array.
I tried adding jest.restoreAllmocks(); in my afterEach method, but this doesn't change anything.
Am I missing something ?