Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

214
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda