From fc508ad57d91a08ee8f74568d60d8b1fa858ee92 Mon Sep 17 00:00:00 2001 From: Ulysse Mavrocordatos Date: Mon, 13 Apr 2026 16:29:51 +0200 Subject: [PATCH] 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) --- features/step_definitions/request_steps.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/step_definitions/request_steps.ts b/features/step_definitions/request_steps.ts index 0feb311fac0e..7350d08e160b 100644 --- a/features/step_definitions/request_steps.ts +++ b/features/step_definitions/request_steps.ts @@ -307,7 +307,7 @@ Then( Then( "the response {string} does not have field {string}", function (this: World, responsePath: string, field: string) { - expect(pathLookup(this.response, responsePath)).to.not.have.property(field.toAttributeName()); + expect(pathLookup(this.response, responsePath)[field.toAttributeName()]).to.be.undefined; } );