TypeError: request.on is not a function when aws-sdk-mock

i see request.on is not function error while using the aws-sdk-mock
Please help

lambda function :
var request = cloudformation.getTemplate({StackName:stackName});
request.on(‘success’, function(response) {
/// code logic
});
request.send();

test :
var AWS = require(‘aws-sdk-mock’);
AWS.setSDK(path.resolve(‘./node_modules/aws-sdk’));

describe(‘handler-sucess’, function(){

beforeEach(function(done){
AWS.mock(‘CloudFormation’, ‘getTemplate’, function (params, callback){
callback(null, “Success”);
});

done();

});
it(‘Test event without RequestType’, function(done){
function(callback){
lambda.handler(thisEvent,thisContext, function(returnCode){
console.log(returnCode);
callback(returnCode);
});
}
],
function(){
//console.log(“nnnformatted:n”+addStreamSpy.getCalls()[0].args);
//expect(responseSpy.getCalls()[0].args[2]).to.equal(“FAILED”)
done();
}
);
});

Read more here: Source link