Fix swapped assertion arguments across test files#37972
Open
jeremymeng wants to merge 1 commit intoAzure:mainfrom
Open
Fix swapped assertion arguments across test files#37972jeremymeng wants to merge 1 commit intoAzure:mainfrom
jeremymeng wants to merge 1 commit intoAzure:mainfrom
Conversation
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>
Contributor
There was a problem hiding this comment.
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/expectedarguments for multiple assertion APIs (equal,strictEqual,deepEqual,deepStrictEqual,notEqual,notDeepEqual) where literals/constants were incorrectly passed asactual. - 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"); |
There was a problem hiding this comment.
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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Assertion methods fixed
assert.equalassert.strictEqualassert.deepEqualassert.deepStrictEqualassert.notEqualassert.notDeepEqualConstant 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.