Skip to content

Commit fc508ad

Browse files
MintsIncclaude
andcommitted
Fix "does not have field" assertion to accept undefined
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 fc508ad

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

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)