DEV Community

Discussion on: Mocking ES6 class methods with Jest!

Collapse
 
jackcaldwell profile image
Jack Caldwell

Looking at the mock function documentation - jestjs.io/docs/en/mock-function-api, you should be able to use mockFn.mockClear(), mockFn.mockReset(), or mockFn.mockRestore() depending on your needs. Hopefully this does what you need.

Collapse
 
09wattry profile image
Ryan

I have tried all of these functions and still the value is either the same or undefined. Any hints?

Thread Thread
 
mattarau profile image
Matt Arau

Have you tried afterEach(() => jest.resetAllMocks()); ?