Relative Content

Tag Archive for javascripttypescriptjestjsmocking

Unable to mock a typescript module in jest correctly

I have a test I’m trying to run and I want to mock a module using jest.mock. However, I can’t seem to get this one to work, in the example below, the original serializeProduct method is always invoked. I’ve tried spies, I’ve tried mocking the module. When I log out the variables that are the mocks/spies they are indeed mock functions at least so the mocking is happening. It’s just that something is causing it to invoke that original method instead of the mock.