During tests using mocha, i'm having invocation issue with S3.getObject().

I am performing a tests using mocha, during test i am getting invocation issue with S3.getObject().

My code in lambda is given here:
index.js: (Inside AWS Lambda function)
S3.getObject(s3FileParams, function(err, data) {
if (err) {
var message = "Error while trying to get file object " + fullFileName + " from bucket " + bucketName + ". Make sure they exist and your bucket is in the same region as this function. Error: " + err;
else {
userMetaDataJson = data.Metadata;

And in the test file index.test.js (using mocha)

AWSMock.mock('S3', 'getObject', function (params, callback){
var metaDataParams = {
"Metadata": {
"startDate": "2016-11-11 12:34:56:000",
"endDate": "2016-11-11 12:34:56:000",
"userName": "userName",
"originalFileName": "originalFileName"
callback(false, metaDataParams);

When running this test with mocha, there is no call to the mocked getObject() and it's calling to the original one.
Is there any other way I can use?

Sign In or Register to comment.