1

I want to create a mock with karate to act on If-None-Match header. I tried to do what is shown here

Scenario: pathMatches('/path') && methodIs('get') && karate.get('requestHeaders.If-None-Match[0]') == '1'
   * def responseStatus = 304
   * def responseHeaders = { 'ETag': '1' }

It is not working. It is ignoring the karate.get part, and using the scenario defined after (the same one without headers):

Scenario: pathMatches('/path') && methodIs('get')
...

What am I doing wrong here?

Serob_b
  • 965
  • 12
  • 29
  • 1
    we may need to improve header support. see this answer if it helps: https://stackoverflow.com/a/72245287/143475 - and if you provide a way to replicate, we can investigate and improve this for future releases: https://github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue – Peter Thomas May 27 '22 at 02:33

1 Answers1

1

Do it like this. I was able to get a response match.

Scenario: pathMatches('/path') && methodIs('get') && headerContains('If-None-Match', '1')
* def responseStatus = 200
* def responseHeaders = {'Etag':'1' }
Dinesh Arora
  • 2,115
  • 3
  • 24
  • 30