Skip to content

Issue reading requestChecksumCalculation when writing a test involving Upload #257

@sawilde

Description

@sawilde

I've been upgrading an code base to use the latest AWS-SDK packages, I have the following snippet of code that I am trying to test (that used to work on the older packages)

const uploader = new Upload({
      client: this.s3Client,
      params: {
        Bucket: destinationBucket,
        Key: destinationKey,
        Body: sourceObject.Body,
      },
      partSize: 5242880 * 4, // 20MB
    });
await uploader.done();

in the test I have configured the following mock

const mockS3 = mockClient(S3Client);

mockS3
      .on(GetObjectCommand, { Key: key, Bucket: bucket })
      .resolves({ Body: sdkStreamMixin(ReadableStream.from('x'.repeat(30e6))) });
// note: there is more mocking but I removed that for brevity as this was the minimum I needed to repeat the issue

when I run the above code it fails with this error

TypeError: Cannot read properties of undefined (reading 'requestChecksumCalculation')

I also tried defining the mock like this

const s3Client = new S3Client({ requestChecksumCalculation: 'WHEN_REQUIRED' });
const mockS3 = mockClient(s3Client);

but the same TypeError

Is there a way to define a mock of a client with specific config to get past this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions