Sinon not stubbing on module.exports
问题 If create an file with the following contents const validateEmail = email => { sendEmail(email); }; const sendEmail = email => { return true; }; module.exports = { validateEmail, sendEmail, }; And a test that tries to stub out the second function... it('Should call sendEmail if a valid email is passed', () => { let sendEmailSpy = sinon.stub(checkEmail, 'sendEmail'); checkEmail.validateEmail('acorrectemail@therightformat.com'); assert.isTrue(sendEmailSpy.called); }); It still calls the