1

I have a scenario where i need to perform a optional match and continue with the execution.. And the value to match is part of an array. The recommendation was to use karate.match() in one of the stackflow answers

Normal flow -

* match response [*].id contains myid // but execution should not halt here.

How to do this using Karate.match() ?

purpletester
  • 47
  • 1
  • 4

1 Answers1

1

Consider this not supported by Karate. What you are asking for does not make sense. You either assert for something or you don't. Else you should just print the response in this case, so you can see it in the report.

If you want to conditionally do something, refer this: https://github.com/intuit/karate#conditional-logic

One hint, this will work:

* def ids = $response[*].id
* if (ids.contains(1)) karate.log('yes')

This is covered in more detail in this answer: https://stackoverflow.com/a/54108755/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248