Problem

Jest is a pretty nice test runner from facebook. Mocking is easy and hairy at the same time given the nature of Javascript.

Code like:

     
     jest.mock("child_process", () => ({
                                __esModule: true,
                                default: { spawn: jest.fn() }
     });

     jest.doMock("child_process", () => ({
                                __esModule: true,
                                default: { spawn: jest.fn() }

might not work properly.

Use unstable_mockModule

I found that jest.unstable_mockModule is a good solution for mocking imported node modules.