-
-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specifying Content-Type serializes Matcher object #1107
Comments
Thanks for this. Unfortunately, matching rules only work on JSON (and XML) content types - not on plain text (or other content types). So it's a bug of sorts that we allow you to put a matching rule in there or that we serialise the matching rule as plain text. If you remove the matcher, I expect it to work (however the provider side would need to match on exact values). |
Thanks for the answer @mefellows , that does indeed work and it's the way we solved it. Is this specific to the V3 matchers or has this always been the case? |
Thanks for confirming. No, this has always been the case for Pact. It could be easily supported now, by creating a plugin for your use case (or creating a general "plain text" one). |
Software versions
Please provide at least OS and version of pact-js
18.16.1
Issue Checklist
Please confirm the following:
Expected behaviour
Testing an api-client for an endpoint that returns a string I create a pact provider that responds with a body and an exact content-type. The matching should only ensure it's a string body, but the content-type header must be exact match:
I expect something like:
Actual behaviour
When providing a content-type header, the actual matcher is serialized to a json-string:
When not providing a content-type header the body is correct but the header is incorrect:
Steps to reproduce
Generated pact-file (stub):
If removing the header in the response the body matching rule is correct but content-type is wrong:
Relevant log files
Please ensure you set logging to
DEBUG
and attach any relevant log files here (or link to a gist).The text was updated successfully, but these errors were encountered: