I have Node.js code that writes a message to an SWS queue. I'm trying to stub this code in my unit tests.
Source:
var AWS = require('aws-sdk');
var sqs = new AWS.SQS({apiVersion: '2012-11-05'});
sqs.sendMessage(myMessage, function(err, data) {
if (err) {
console.log("Error", err);
});
In My unit tests I'm trying to do something like this to stub the call:
sandbox = sinon.createSandbox();
sandbox.stub(AWS.SQS,'sendMessage').callsFake((message,fn) => {
console.log("Stub AWS sendMessage");
});
sandbox.restore();
I am getting this error: TypeError: Cannot stub non-existent own property sendMessage