Support for YAML Indexing and Advanced Assertions
Closed this issue · 1 comments
varsharyalii commented
Description:
Consider a scenario where there is a list of items with quantities, and the goal is to assert the quantity of a specific item in a specific position without triggering a pass due to the presence of the same quantity in another position.
- test: Verify quantity for the third item
stages:
- response:
status_code: 200
json:
items:
- name: "Item1"
quantity: 5
- name: "Item2"
quantity: 10
- name: "Item3"
quantity: 5
The provided example should only match the quantity of the third item and not inadvertently pass due to the presence of the same quantity elsewhere in the list.
I wish there was someplace I could add !index=2 or something as such
This is especially causing a blocker while trying to run negative tests
michaelboulton commented
You can use jmespath assertions like
tavern/tests/integration/test_jmes.tavern.yaml
Lines 215 to 225 in 4396844