'How to configure a dockerized Mockserver to match requests by regex body
I'd like to create a Mockserver expectation for a given mocked url that should return:
- response "A" if the body contains the string "myPattern"
- response "B" if the body NOT contains the string "myPattern"
I have a dockerized Mockserver so I have to add an entry in the initializer json config file. Following Mockserver doc, I have understood that a regex body approach should work:
this is my config snippet to deal with:
matcher for response "A":
"body":{ "type":"REGEX", "regex":"(myPattern)" }matcher for response "B":
"body":{ "type":"REGEX", "regex":"^(myPattern)" }
The pattern works well in regex on line tester, but id doesn't work for Mockserver as I'm getting "didn't match expectation" for all the requests due to "body didn't match" error.
How do you suggest to fix it?
TIA
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
