Skip to content

Conversation

@trivikr
Copy link
Member

@trivikr trivikr commented Jan 14, 2026

Issue

Noticed while examining e2e test output in JS-6477

Description

Checks for content-type in input and output when different protocol is passed.
Also saves time while executing test by listing just one queue.

Testing

Before

Prints lot of debug statements, and doesn't check for content-type used by protocol.

$ client-sqs> yarn test:e2e test/SQS.e2e.spec.ts

 RUN  v3.2.4 /local/home/trivikr/workspace/aws-sdk-js-v3/clients/client-sqs

stdout | test/SQS.e2e.spec.ts > SQS > can make requests with AwsQueryProtocol
200 POST SQSClient ListQueuesCommand
    https://sqs.us-west-2.amazonaws.com/
    >>== Request Headers: {
      "content-type": "application/x-www-form-urlencoded",
      "content-length": "36",
      "x-amz-user-agent": "aws-sdk-js/3.968.0",
      "user-agent": "aws-sdk-js/3.968.0 ua/2.1 os/linux#5.10.247-246.989.amzn2int.x86_64 lang/js md/nodejs#20.19.0 api/sqs#3.968.0 m/E,w,v",
...
 Test Files  1 passed (1)
      Tests  2 passed (2)
   Start at  02:36:01
   Duration  599ms (transform 100ms, setup 0ms, collect 174ms, tests 169ms, environment 0ms, prepare 91ms)

After

Doesn't print debug statements, and checks for content-type used by protocol.

$ client-sqs> yarn test:e2e test/SQS.e2e.spec.ts
...
 Test Files  1 passed (1)
      Tests  2 passed (2)
   Start at  02:33:26
   Duration  593ms (transform 108ms, setup 0ms, collect 174ms, tests 160ms, environment 0ms, prepare 101ms)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@trivikr trivikr requested a review from a team as a code owner January 14, 2026 02:36

it(`can make requests with ${client.config.protocol.constructor.name}`, async () => {
const queues = await client.listQueues();
expect(queues.QueueUrls ?? []).toBeInstanceOf(Array);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test should retain this brief assertion of the output JS structure, shallow though it may be

Copy link
Member Author

@trivikr trivikr Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always be true, since it's always an instance of Array (even if QueueUrls is undefined)

Welcome to Node.js v20.19.0.
Type ".help" for more information.
> (undefined ?? []) instanceof Array
true

If there are no queues in the account, QueueUrls is undefined

{
  '$metadata': {
    httpStatusCode: 200,
    requestId: '7652a27f-b8b7-56a0-9887-c39ebdf93168',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  }
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have expect.assertions to confirm that assertions inside middleware are called.

I still added check for httpStatusCode in 598e2ed

},
{ step: "build" }
);
await client.listQueues({ MaxResults: 1 });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await client.listQueues({ MaxResults: 1 });
const queues = await client.listQueues({ MaxResults: 1 });
expect(queues.QueueUrls ?? []).toBeInstanceOf(Array);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added check for httpStatusCode in 598e2ed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants