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

79
Vistas
Which createReadStream am I calling here?

I'm trying to mock a call to S3 using the aws-sdk-mock package. I want to mock getObject on a bucket, so that instead of createReadStream() creating a network stream from a bucket, it creates a readable stream from a local file in my test suite.

Here's how I'm mocking the s3 call:

s3Spy = AWS.mock("S3", "getObject", {
    createReadStream: () => {
        return fs.createReadStream(testDataFile)
    }
});

Here's the line where it is used:

const stream = s3.getObject(params).createReadStream();

I can trace stream with a console.log call, and it's clearly a readable:

console.log(stream)
Readable {
  _readableState: ReadableState {
    ...
  },
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  _read: [Function (anonymous)],
  [Symbol(kCapture)]: false
}

However, if I inspect it further, it's not a file readable:

console.log(stream.path)
undefined

Which createReadStream am I calling if it's not the one in my mock? How can I write this so that I pull in the mocked data that I want to use?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I solved the problem by changing the mocking code:

s3Spy = AWS.mock("S3", "getObject", fs.createReadStream(testDataFile));
about 4 years ago · Juan Pablo Isaza Denunciar
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