I want to match against an expected string body (requiredBody) rather than a JSON object because I want to verify that my transformData functions are working as intended. Matching against a string should be more representative of what the adapter sees in real life.
However, as you can see in the isBodyMatching source below, this will fail, because the actual string body will be parsed before it is compared to my requiredBody string.
Fix: The parsing below should not be performed if requiredBody is a string.
I want to match against an expected string body (requiredBody) rather than a JSON object because I want to verify that my
transformData
functions are working as intended. Matching against a string should be more representative of what the adapter sees in real life.However, as you can see in the isBodyMatching source below, this will fail, because the actual string body will be parsed before it is compared to my requiredBody string.
Fix: The parsing below should not be performed if requiredBody is a string.
As a workaround, I implemented the comparison in a function(config) passed to reply.
Another workaround might be to use a RequestDataMatcher with an
asymmetricMatch
.