Serob_b
Serob_b

Reputation: 1069

Karate pathMatches exclusion

I would like to have possibility in Karate to match all paths except /example/path, to have something like this:

pathMatches ('!/example/path')

Is there such possibility?

Upvotes: 1

Views: 449

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58098

You can use the requestUri variable which will be always set automatically. The nice thing about the design is you can use "normal" Java Script and achieve any combination you want, pathMatches() is just pre-defined for convenience.

So this should get you what you want, try it !

Scenario: !requestUri.startsWith('/example/path')

EDIT: silly me, I just realized that you have a much better option, again "because JavaScript". This will work !

Scenario: !pathMatches('/example/path')

Upvotes: 1

Related Questions