I’m currently setting up Pact tests for a provider, and I’m encountering issues with XML response validation. The provider tests are failing due to mismatches in the XML response body that appear to be caused by differences in whitespace and new lines.
Is there a way in Pact to ignore whitespace and new line differences when validating XML response bodies? Alternatively, is there a way to configure the provider verification to only validate the response status code and headers without considering the body content?
I tried to add validateResponses in verifierOption to only validate response status code and header in the bellowing snippet code:
const verifierOptions = {
validateResponses: {
headers: true,
status: true,
body: false // Ignoring the body validation doesn't seem to work as expected
},
};
But the provider validation still validate full response of status code, headers and body
validateResponses: {
headers: true,
status: true,
body: false // Ignoring the body validation doesn't seem to work as expected
},
This doesn't look like a valid JS verification option - where are you getting this suggestion from?
Is there a way in Pact to ignore whitespace and new line differences when validating XML response bodies?
Yes, Pact JS supports XML matching (see XML docs). This suggests either you're on an old version that doesn't support XML matching, that you are doing something that is unexpected or that there is a bug. To find out, we need a minimal reproducible example.
Alternatively, is there a way to configure the provider verification to only validate the response status code and headers without considering the body content?
Yes, don't include a body in the consumer test (but this is not a very helpful test)