Mocking shelljs with Jest - [TypeError: shell.exec is not a function]
问题 As mentioned in my previous question about mocking, I am new to Jest and testing and I seem to be getting some curveballs. This time around I am having trouble mocking shelljs in my CLI application. Automocking jest.mock('shelljs'); didn't work and errored as:[TypeError: shell.exec is not a function] So I went ahead and tried to use mockImplementation() jest.mock('shelljs', () => { return jest.fn().mockImplementation(() => { return { exec: () => {} }; }); }); To my surprise I am still getting