Skip to content

Commit 457efca

Browse files
Add step to assert a field is not present (#1554)
* Add step to assert a field is not present * Fix method naming --------- Co-authored-by: skarimo <[email protected]>
1 parent c13bcc6 commit 457efca

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.generator/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,11 @@ def expect_response_has_field(context, response_path, field):
465465
"""Check that a response has field."""
466466

467467

468+
@then(parsers.parse('the response "{response_path}" does not have field "{field}"'))
469+
def expect_response_does_not_have_field(context, response_path, field):
470+
"""Check that a response path does not have field."""
471+
472+
468473
@then(parsers.parse('the response "{response_path}" has item with field "{key_path}" with value {value}'))
469474
def expect_array_contains_object(context, response_path, key_path, value):
470475
"""Check that a response attribute contains an object with the specified key and value."""

features/step_definitions/request_steps.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,13 @@ Then(
297297
}
298298
);
299299

300+
Then(
301+
"the response {string} does not have field {string}",
302+
function (this: World, responsePath: string, field: string) {
303+
expect(pathLookup(this.response, responsePath)).to.not.have.property(field);
304+
}
305+
);
306+
300307
Then(
301308
"the response {string} has length {int}",
302309
function (this: World, responsePath: string, fixtureLength: number) {

0 commit comments

Comments
 (0)