Skip to content

Commit f569eb4

Browse files
MintsIncclaude
andauthored
Fix "does not have field" assertion to accept undefined (#3922)
ObjectSerializer.deserialize() always assigns `instance[attr] = undefined` for optional fields absent from the JSON response, so the property key exists on the object even when the field was not present. Chai's `.not.have.property()` uses hasOwnProperty() which returns true for undefined-valued keys, causing the assertion to fail. Treat a property value of `undefined` as equivalent to "field not present" by asserting the value `.to.be.undefined` instead of checking key existence. Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 8bdd5b9 commit f569eb4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

features/step_definitions/request_steps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ Then(
307307
Then(
308308
"the response {string} does not have field {string}",
309309
function (this: World, responsePath: string, field: string) {
310-
expect(pathLookup(this.response, responsePath)).to.not.have.property(field.toAttributeName());
310+
expect(pathLookup(this.response, responsePath)[field.toAttributeName()]).to.be.undefined;
311311
}
312312
);
313313

0 commit comments

Comments
 (0)