Trying to Test functionality in my lambda

I am trying to test functionality in my lambda, some of this functionality makes calls to DynamoDB to update. I need this to resolve so that my test does not fail. I am using aws-sdk-mock. I will include my call to Dynamo and my test.
//DB call
database.update(parameters).promise();

//test
it('Response Message', async () => {
const response = await helper.handler(variable, async () => {
AWS.mock('DynamoDB', 'update', Promise.resolve());
});

assert.equal(Anything, Anything);

});
I have tried different variations but this is just an example.

Comments

  • I would take a look at using DynamoDB Local instead of mocking DynamoDB. You get the benefit of knowing your SDK calls are valid (since DynamoDB Local validates requests just like real DynamoDB) and you don't have to worry about the complications of mocking requests with realistic-looking responses that may not accurately reflect how real DynamoDB would respond.

Sign In or Register to comment.