vitmont
12/01/2023, 4:58 PM{"field-a": "a", "field-b": "this is the value for field b"}
Is there a way to write the test config similar to the following?
yaml
- vars:
var1: xyz
assert:
- type: is-json
- type: equals
var: output["field-a"]
value: "a:"
- type: similar
var: output["field-b"]
value: value for field b
I could have separate test configs/providers that output just the different parts of the JSON output, but it can get messy pretty quick
(also thanks in advance, the multiple __expected columns have worked great )ian
12/02/2023, 5:42 AMyaml
assert:
- type: is-json
- type: javascript
value: output.fieldA === 'foo'
unfortunately that will just work for logical assertions, and you wouldn't be able to use things like similarity
for similar, you could use the postprocess directive to do something like this. postprocess applies to the entire test case:
yaml
tests:
- postprocess: output.fieldA # returns only fieldA from the output
assert:
- type: similar
value: foo
Hope this helps!vitmont
12/06/2023, 5:23 PM