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.
How to mock a single file from external package with Jest?
I’m working on a product in Typescript that uses some external package (written in JS if it matters) via npm. In the test i’d like to mock only one JS file from that package.