Skip to content

Fix swapped assertion arguments across test files#37972

Open
jeremymeng wants to merge 1 commit intoAzure:mainfrom
jeremymeng:fix/swap-assertion-arguments
Open

Fix swapped assertion arguments across test files#37972
jeremymeng wants to merge 1 commit intoAzure:mainfrom
jeremymeng:fix/swap-assertion-arguments

Conversation

@jeremymeng
Copy link
Copy Markdown
Member

Description

Fix 303 swapped assertion arguments across 45 test files where a constant literal was incorrectly passed as the first (actual) argument instead of the second (expected) argument.

For example:

// Before (incorrect): constant in actual position
assert.equal(200, res.statusCode);

// After (correct): actual value first, expected constant second
assert.equal(res.statusCode, 200);

Assertion methods fixed

  • assert.equal
  • assert.strictEqual
  • assert.deepEqual
  • assert.deepStrictEqual
  • assert.notEqual
  • assert.notDeepEqual

Constant types caught

Number literals, string literals, boolean literals (true/false), null, undefined, object literals ({}), and array literals ([]).

Packages affected

appconfiguration, attestation, core-client, cosmosdb, deviceupdate, easm, eventgrid, healthdataaiservices, keyvault, loadtesting, search, servicebus, storage (blob, datalake, avro, changefeed), textanalytics, translation, and web-pubsub.

This is a test-only change with no functional impact, but correcting argument order ensures assertion failure messages display the actual vs expected values correctly.

Swap the actual and expected arguments in assert.equal, assert.strictEqual,
assert.deepEqual, assert.deepStrictEqual, assert.notEqual, and
assert.notDeepEqual calls where a constant literal was incorrectly passed
as the first (actual) argument instead of the second (expected) argument.

This affects 303 assertions across 45 test files in appconfiguration,
attestation, core-client, cosmosdb, deviceupdate, easm, eventgrid,
healthdataaiservices, keyvault, loadtesting, search, servicebus, storage,
textanalytics, translation, and web-pubsub packages.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR standardizes assertion argument ordering across a broad set of test suites so that assertion failures report actual vs. expected values correctly (e.g., assert.equal(actual, expected)), improving debuggability without changing product code behavior.

Changes:

  • Swapped actual/expected arguments for multiple assertion APIs (equal, strictEqual, deepEqual, deepStrictEqual, notEqual, notDeepEqual) where literals/constants were incorrectly passed as actual.
  • Applied these updates across multiple SDK packages’ test files (test-only refactor).

Reviewed changes

Copilot reviewed 45 out of 45 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
sdk/web-pubsub/web-pubsub/test/public/odata.spec.ts Fixes swapped assert.equal args for odata string assertion.
sdk/web-pubsub/web-pubsub-express/test/validate.spec.ts Fixes swapped assert.equal args for response header assertion.
sdk/web-pubsub/web-pubsub-express/test/user.spec.ts Fixes swapped assertion args across multiple handler/status/header checks.
sdk/web-pubsub/web-pubsub-express/test/disconnected.spec.ts Fixes swapped assert.equal args for status code assertion.
sdk/web-pubsub/web-pubsub-express/test/ctor.spec.ts Fixes swapped assert.equal args for path assertions.
sdk/web-pubsub/web-pubsub-express/test/connected.spec.ts Fixes swapped assert.equal args for status code assertion.
sdk/web-pubsub/web-pubsub-express/test/connect.spec.ts Fixes swapped assertion args across status/state/body checks.
sdk/web-pubsub/web-pubsub-client/test/client.spec.ts Fixes swapped assert.equal args for protocol name assertion.
sdk/web-pubsub/web-pubsub-client/test/client.lifetime.spec.ts Fixes swapped assert.equal args in polling/spin-check assertions.
sdk/translation/ai-translation-document-rest/test/public/node/documentTranslationTest.spec.ts Fixes swapped assert.equal args for progress assertion.
sdk/textanalytics/ai-text-analytics/test/public/textAnalyticsClient.spec.ts Fixes swapped assert.equal args in opinion mining assertions.
sdk/storage/storage-internal-avro/test/node/avroreader.spec.ts Fixes swapped strictEqual/deepStrictEqual args in avro test cases.
sdk/storage/storage-file-datalake/test/node/pathclient.spec.ts Fixes swapped deepStrictEqual/notDeepEqual args in counter/token assertions.
sdk/storage/storage-blob/test/node/containerclient.spec.ts Fixes swapped strictEqual args for boolean existence checks.
sdk/storage/storage-blob/test/node/avroreader.spec.ts Fixes swapped strictEqual/deepStrictEqual args in avro test cases.
sdk/storage/storage-blob-changefeed/test/blobchangefeedclient.spec.ts Fixes swapped assert.equal args across changefeed event property assertions.
sdk/servicebus/service-bus/test/internal/unit/receiverCommon.spec.ts Fixes swapped assert.equal args for error message assertion.
sdk/servicebus/service-bus/test/internal/unit/receiver.spec.ts Fixes swapped assert.equal args for error name/message assertions.
sdk/servicebus/service-bus/test/internal/unit/linkentity.unittest.spec.ts Fixes swapped assert.equal args for error message assertion.
sdk/servicebus/service-bus/test/internal/unit/batchingReceiver.spec.ts Fixes swapped assert.equal args in timer math and length assertions.
sdk/servicebus/service-bus/test/internal/smoketest.spec.ts Fixes swapped assert.equal/deepEqual args in helper validations.
sdk/search/search-documents/test/public/node/searchClient.spec.ts Fixes swapped assert.deepEqual args for result ID arrays.
sdk/loadtesting/load-testing-rest/test/public/node/testRun.spec.ts Fixes swapped assert.equal args for status string assertion.
sdk/keyvault/keyvault-keys/test/public/node/crypto.spec.ts Fixes swapped assert.equal args for algorithm assertions.
sdk/healthdataaiservices/health-deidentification-rest/test/public/jobOperationsTest.spec.ts Fixes swapped assert.equal args in job status/error code assertions.
sdk/eventgrid/eventgrid-namespaces/test/public/eventGridNamespacesClient.spec.ts Fixes swapped assert.equal args for receive result length assertion.
sdk/easm/defender-easm-rest/test/public/savedFiltersTest.spec.ts Fixes swapped assert.strictEqual args for description assertion.
sdk/easm/defender-easm-rest/test/public/assetsTest.spec.ts Fixes swapped assert.strictEqual args for state/phase assertions.
sdk/deviceupdate/iot-device-update-rest/test/public/update.spec.ts Fixes swapped assert.equal args for status string assertions.
sdk/deviceupdate/iot-device-update-rest/test/public/management.spec.ts Fixes swapped assert.equal args for status string assertions.
sdk/cosmosdb/cosmos/test/public/integration/authorization.spec.ts Fixes swapped assert.equal args for created document id assertion.
sdk/cosmosdb/cosmos/test/public/functional/spatial.spec.ts Fixes swapped assert.equal args for length/id assertions.
sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts Fixes swapped assert.strictEqual args for expected status assertion.
sdk/cosmosdb/cosmos/test/public/functional/database.spec.ts Fixes swapped assert.equal args for thrown error message assertions.
sdk/cosmosdb/cosmos/test/public/functional/container.spec.ts Fixes swapped assert.equal args for indexing policy assertions.
sdk/cosmosdb/cosmos/test/public/functional/clientSideEncryption.spec.ts Fixes swapped assert.equal args for result length assertion.
sdk/cosmosdb/cosmos/test/internal/unit/sessionContainer.spec.ts Fixes swapped assert.equal args for session token assertion.
sdk/cosmosdb/cosmos/test/internal/unit/inMemoryCollectionRoutingMap.spec.ts Fixes swapped assert.equal args in routing map assertions.
sdk/core/core-client/test/serializer.spec.ts Fixes swapped assert.strictEqual args in serializer assertions.
sdk/attestation/attestation/test/public/attestationTokenTests.spec.ts Fixes swapped equal/deepEqual/notEqual args across token tests.
sdk/appconfiguration/app-configuration/test/public/throwOrNotThrow.spec.ts Fixes swapped assert.equal args for status code assertion.
sdk/appconfiguration/app-configuration/test/public/index.spec.ts Fixes swapped assert.equal args for status/value assertions.
sdk/appconfiguration/app-configuration/test/public/etags.spec.ts Fixes swapped assert.equal args for status/value assertions.
sdk/appconfiguration/app-configuration/test/internal/node/http.spec.ts Fixes swapped assert.equal args for sync token header assertions.
sdk/appconfiguration/app-configuration/test/internal/helpers.spec.ts Fixes swapped assert.equal/deepEqual args in helper tests.

connectionPolicy: { enableBackgroundEndpointRefreshing: false },
});
assert.equal("document1", createdDoc.id, "invalid documnet create");
assert.equal(createdDoc.id, "document1", "invalid documnet create");
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

Typo in assertion message: "documnet" should be "document".

Suggested change
assert.equal(createdDoc.id, "document1", "invalid documnet create");
assert.equal(createdDoc.id, "document1", "invalid document create");

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants