Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

213
Views
mocking S3.listObjectsV2

I would want to moc the call function the call to s3.listObjectV2.

I am only in need of the contents of what's returned.

public async init() {
        AWS.config.update({
            region: config.aws.region,
        })

        const s3 = new AWS.S3({ apiVersion: config.aws.S3.apiVersion })

        let params = { Bucket: config.aws.S3.ctrPredictorModelBucket }
        const data = await s3.listObjectsV2(params).promise()
        return data.contents
}
            

Then in the test, I would want to do before every test something like

before( () => {

        s3 = mock.mock(AWS.S3)
        // request = mock.mock(AWS.Request)
        
        mock.when(s3.listObjectsV2(mock.anything()).thenReturn(Return_object))
         
    })

with Return_objecy only contains what is needed.

But the current way things are set I get an error saying the s3.listObjectsV2 is not a function

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!