According to Karate documentation for contains short-cuts The following match arguments should work and do the same:
@test_contains_only
Scenario: Test contains only shortcut
* def expected = [ "a", "b", "c", "d" ]
* def to_match = { "properties": { "additional_information": "Some put-updated info", "types": [ "a", "b", "c", "d" ] } }
* print to_match.properties.relation_types
# This will pass
* match to_match.properties contains deep
"""
{
"additional_information": "Some put-updated info",
"types": [ "a", "b", "c", "d" ]
}
"""
# This will pass
* match to_match.properties.types == '#(^^expected)'
# This will fail
* match to_match.properties contains deep
"""
{
"additional_information": "Some put-updated info",
"types": '#(^^expected)'
}
"""
When executing the above, I get this error:
* match to_match.properties contains deep
"""
{
"additional_information": "Some put-updated info",
"types": '#(^^expected)'
}
"""
match failed: CONTAINS_DEEP
$ | actual does not contain expected | all key-values did not match, expected has un-matched keys - [types] (MAP:MAP)
{"additional_information":"Some put-updated info","types":["a","b","c","d"]}
{"additional_information":"Some put-updated info","types":"#(^^expected)"}
$.types | actual does not contain expected | actual array does not contain expected item - #(^^expected) (LIST:STRING)
["a","b","c","d"]
'#(^^expected)'
$.types[3] | data types don't match (STRING:LIST)
'd'
["a","b","c","d"]
$.types[2] | data types don't match (STRING:LIST)
'c'
["a","b","c","d"]
$.types[1] | data types don't match (STRING:LIST)
'b'
["a","b","c","d"]
$.types[0] | data types don't match (STRING:LIST)
'a'
["a","b","c","d"]
In my opinion, using '#(^^expected)' doesn't work as expected. Or is it happening because I'm using match to_match.properties contains deep together with the ^^ (contains only shortcut)?
I'm using Karate v1.2.0. The same scenario doesn't fail in v1.0.1.