karate

Assert array not present with each match


After upgrade to latest version of karate (1.1.0 to 1.4.1) this line is no longer working

And Match each response[*].foos[*].bars == "#notpresent"

foos and bars are arrays

I want to assert that in foos array each object do not contain an array field bars

It failed

match failed: EACH_EQUALS
  $ | match each failed, empty array / list (LIST:STRING)
  []
  '#notpresent'

Solution

  • Please read the release notes: https://github.com/karatelabs/karate/releases/tag/v1.4.1

    I think your assertion is wrong and the change actually forces you to correct your test. I recommend something like this:

    * match each response.foos !contains { bars: '#present' }
    

    If you really want to revert to the old behavior (which I don't think is right in your case) you can do this:

    * configure matchEachEmptyAllowed = true