jupiter / simple-mock

Super simple stubs and spies with 1-step sandbox restore
MIT License
87 stars 12 forks source link

How can I mock nested function calls? #31

Closed frankli-dev closed 4 years ago

frankli-dev commented 4 years ago
  const s3 = aws.getS3();

  const params = {
    Bucket: process.env.AWS_S3_BUCKET,
    Key: filename
  };

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

I would like to mock const stream = s3.getObject(params).createReadStream() but not sure how I can do this with simple-mock

Please help Thanks in advance,

frankli-dev commented 4 years ago

Oops. I've found the solution by mocking the getObject function with an object that returns createReadStream I thought in the wrong way.

Great lib.