Reputation: 289
I've got a request that returns a response node(itemCanBe) value in two possible ways, depending on the 'itemNum'. How do I assert this ? below attempt is not working
* match res..itemCanBe == null || res..itemCanBe[*] contains ['Colgate']
itemCanBe returning null
{
"itemDetails": {
"1234": {
"itemNum": "1234",
"itemCanBe": null
}
}
}
itemCanBe returning array
{
"itemDetails": {
"4567": {
"itemNum": "4567",
"itemCanBe": [
"Colgate",
"Sensodine"
]
}
}
}
Upvotes: 1
Views: 924
Reputation: 21
See this thread for details: https://github.com/intuit/karate/issues/1202#issuecomment-653632397 This should be good enough to solve your problem.
Upvotes: 2
Reputation: 58058
This will actually work:
* def temp = get[0] response..itemCanBe
* match temp == '##[]'
Also refer: https://stackoverflow.com/a/50350442/143475
Upvotes: 1