1

i'm trying to check if an array doesn't cointain an element, but i have issues when the array is null:

Scenario Outline: Not contains
* match <foo> !contains 'c'
Examples:
|foo|
|['a']|
|null|

Any advice to write a match that is true also when the array is null?

Thanks

1 Answers1

0

Developer of Karate here, it does not make sense to do a contains on a null, so I would try to not mix such cases. Just write a separate Scenario if needed, and I have some generic advice for teams here.

That said, read this if it helps: https://stackoverflow.com/a/50350442/143475

In short, Karate does not support what you want - so please consider re-writing your test or contributing code to Karate.

Unless you are okay with this:

* def original = null
* def actual = original ? original : []
* match actual !contains 'c'
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248