esbuild-jest
esbuild-jest copied to clipboard
Mocking in jest doesn't work
I can't put a finger on the specific issue but what I experience is that my mocks gets stubbed (i.e return some default value as undefined
) but doesn't treat .mockImplemenation
or .mockRetrunValue
at all.
I could see this issue https://github.com/aelbore/esbuild-jest/issues/12 but updating to latest hasn't fixed it for me 😿
Same here - I tried both the latest and [email protected] builds. My jest mocks are not being mocked above my application code.
I'm using doMock specifically for context.
When I changed the behavior to using mock, it was able to hoist the function and it actually worked!
However any helper functions that I want to pass in are not initialized and don't let me me check if they have been called.
i.e. expect(mockRetrieveBalance).toHaveBeenCalled();
Error: "Cannot access 'mockRetrieveBalance' before initialization"
Any news on this issue ?