Questions tagged [aws-sdk-mock]

Easily mock aws-sdk API methods to enable easier testing of applications which use the AWS SDK for JavaScript

36 questions
1
vote
0 answers

AWS DynamoDB mock always matching

I am mocking DynamoDB query using aws-sdk-mock. It seems what ever query params I pass it will always match. For example looking at the implementation: const AWS = require("aws-sdk"); ... const dynamoDB = new AWS.DynamoDB.DocumentClient(); await…
1
vote
1 answer

Unit Testing Using Jest and AWS-SDK-Mock, Mock DynamoDB Scan

Jumping into Jest and unit testing lambda functions. I'm trying to mock the aws dynamodb-document client scan in my unit test. I'm getting back the actual scan from the real db though so i know something with my mock isn't working. This is my…
Tim B
  • 215
  • 1
  • 2
  • 12
1
vote
1 answer

AWS Mock not able to mock Lambda invoke()

I am trying to mock an Lambda.invoke() call in my Jest. However, the mock call didn't work and instead executed the real invoke() method which leads to not authorized to perform: lambda:InvokeFunction. I couldn't find out what's wrong as I did the…
jl90
  • 639
  • 2
  • 10
  • 24
1
vote
1 answer

Troubleshooting AWS mocks in NodeJS

I have the following test: const AWSMock = require('aws-sdk-mock'); const AWS = require('aws-sdk'); const sinon = require('sinon'); function sendMetric() { const cloudwatch = AWS.CloudWatch(); cloudwatch.putMetricData(); } describe('Meh',…
HenryTK
  • 1,287
  • 8
  • 11
1
vote
1 answer

Mocking aws-sdk promises with aws-sdk-mock using jest

can you please see below code and tell me what is wrong with it? The code times out after 5 seconds, but I would expect it to run just fine, as per official description. Does anyone see what is fundamentally wrong? import * as AWS from…
wzr1337
  • 3,609
  • 5
  • 30
  • 53
1
vote
1 answer

NodeJS: Mock promise of aws-sdk

I am currently working on some code in NodeJS. My code looks like this: const AWS = require('aws-sdk'); const PARAMS_ACCOUNT = { AttributeNames: [ "max-instances" ] }; const ec2 = new AWS.EC2(); const getAccountAttributes =…
Kmmel
  • 186
  • 1
  • 1
  • 15
1
vote
1 answer

getObject mock is returning 0 bytes file

getObject mock is returning 0 bytes file. My mock requirement is to get the complete file. I have code as follows: AWSmock.mock("S3", "getObject", (params: any, callback: any) => { try { const filePath = path.join(__dirname,…
kn_pavan
  • 1,510
  • 3
  • 21
  • 42
0
votes
0 answers

How can I mock a DynamoDB scan operation using aws-sdk-mock?

I`ve beed following the aws-sdk-mock documentation to mock a DynamoDB service so I can test my functions, which works fine like this: const AWSMock = require("aws-sdk-mock"); const AWS = require("aws-sdk"); const mockedData =…
0
votes
0 answers

How to test GetParameter of SSM using aws-sdk-client-mock in typescript

I want to write test case for SSM GetParameterCommand request in typescript. My code looks like: const region = "us-east-1" const awsSSMClient = new SSMClient({ region }) export async function fetchParam(parameterName: string, decrypt: boolean):…
0
votes
1 answer

Mocking AWS SDK using jest

Newbie to AWS ! I have written a function which creates a secretID in AWS secret manager and stores some token value into it. This is the snip of my function create-secret.ts import * as AWS from 'aws-sdk'; const secretsManager = new…
0
votes
1 answer

How do you specify the code behind the mocked AWS Lambda

I'm currently in the phase of unit-testing my lambdas and this is the first time I'm doing this, so please bear with me. I've done my researches about this, and I think I managed to pinpoint down to which package I should use and which method. As…
Fares
  • 893
  • 1
  • 11
  • 24
0
votes
1 answer

Mock Lambda.invoke wrapped but not being called

I'm having an issue while trying to mock lambda.invoke which I'm calling from within another lambda function. The function is wrapped (I can't use sinon after, it will tell me it's already wrapped). The test keeps calling the lambda function on AWS…
GwenM
  • 1,198
  • 10
  • 24
0
votes
1 answer

jest-aws-sdk-mock broke when updating dependencies

The application itself is a Lambda handler written in Node. After "npm update", some of the sub-dependencies, babel?, is most likely interfering and doing something that have changed. Our AWS code is initialised in one module looking like…
lobbin
  • 127
  • 1
  • 12
0
votes
1 answer

Mock Javascript AWS.RDS.Signer

I have Connection class that is used to connect to AWS Rds Proxy via IAM Authentication. Part of that process is to create a token. I have a function to create the token but now I having a hard time to mock and test it. Here is the Connection class…
navig8tr
  • 1,724
  • 8
  • 31
  • 69
0
votes
1 answer

How to mock typescript services and functions that use AWS resources?

I am having a Typescript backend structure and I want to create unit tests for all the functionalities. I am using JEST and aws-skd-mock for mocking AWS. I have tried some things but it seems I am not doing the right thing. I have this service where…
ROKIKOKI
  • 571
  • 2
  • 9
  • 24