mercredi 29 avril 2015

Stubbing with proxyquire

How would I stub the following module with proxyquire and sinon:

var email = require("emailjs").server.connect.send();

I did the following, but its not working, because when I try to trigger an error within send() it still sends the email.

sendMailStub = sinon.stub(email, "send");    
testedModule = proxyquire('../index.js', {
                'email': {
                    'server': {
                        'send': sendMailStub
                        }
                    }
            });

And also tried:

testedModule = proxyquire('../index.js', {
            email: {send: sendMailStub}
        });

Aucun commentaire:

Enregistrer un commentaire