You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since there seems to be an ambiguity in the PACT specification regarding JSON string bodies. If the body is only a string, it is not interpreted as JSON like for objects and arrays but as plain text that is passed to the PACT provider test. Thus, the provider cannot parse the body EXPIRED since it is not valid JSON.
The text was updated successfully, but these errors were encountered:
This seems to be a problem in pact-ffi. I've ran the same code you've shared and enabled all logging. PactSwift sends the following Pact data to pact-ffi:
{"metadata":{"pactSpecification":{"version":"3.0.0"},"pactSwift":{"version":"0.12.0"}},
"interactions":[{"response":{"status":200,"body":"\"EXPIRED\""},"providerState":"elements exist","request":{"path":"\/elements","method":"get"},
"description":"Request for a list"}],"provider":{"name":"unit-test-api-provider"},
"consumer":{"name":"pactswift-unit-tests"}}
Will pass this on to pact-ffi team. Thanks for reporting it.
What possible values are you expecting? Could you use another matcher? Maybe OneOf? It uses a regex as a base and sets the Pact with " around your expected string:
Nevermind... Still have holiday brain π€·ββοΈ
β Question
How can we generate the PACT JSON file so that it contains a quoted string a body (e.g.
"body": "\"EXPIRED\""
)?π¬ Context
We want to write a PACT consumer test for a back-end API that returns only a single string as response, e.g.
"EXPIRED"
In our consumer, we write
that leads to a successful execution of our test with the client but generates the wrong JSON for that is published to the PACT broker:
Expected
Actual
Since there seems to be an ambiguity in the PACT specification regarding JSON string bodies. If the body is only a string, it is not interpreted as JSON like for objects and arrays but as plain text that is passed to the PACT provider test. Thus, the provider cannot parse the body
EXPIRED
since it is not valid JSON.The text was updated successfully, but these errors were encountered: