Artur Neumann
07/04/2022, 10:56 AMPactffiWithBody(arg 2) expected a string
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Artur Neumann
07/04/2022, 11:08 AMTimothy Jones
07/04/2022, 11:09 AMTimothy Jones
07/04/2022, 11:09 AMTimothy Jones
07/04/2022, 11:09 AMArtur Neumann
07/04/2022, 11:10 AMprovider.uponReceiving(`as '${user}', a PUT request to upload a file to '${file}'`)
.withRequest({
method: 'PUT',
...
contentType: 'text/plain; charset=utf-8'
})
.willRespondWith(response)
but this not
provider.uponReceiving(`as '${user}', a PUT request to upload a file to '${file}'`)
.withRequest({
method: 'PUT',
...
contentType: MatchersV3.regex('text/plain(;()?charset=(utf|UTF)-8)?', 'text/plain; charset=utf-8')
})
.willRespondWith(response)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Artur Neumann
07/05/2022, 3:39 AMPactffiWithBody(arg 2) expected a string
Matt (pactflow.io / pact-js / pact-go)
Artur Neumann
07/05/2022, 3:48 AMMatt (pactflow.io / pact-js / pact-go)
contentType
property cannot be a matcher (see the type definition). It says “this is the content type of this request”. It’s an optional field though.Matt (pactflow.io / pact-js / pact-go)
contentType
but set the header Content-Type
and use the matcher there - that should work as you expectArtur Neumann
07/05/2022, 3:49 AMMatt (pactflow.io / pact-js / pact-go)
Artur Neumann
07/05/2022, 3:50 AM'text/xml; charset=utf-8'
is valid but also
'application/xml; charset=UTF-8'
Matt (pactflow.io / pact-js / pact-go)
withResponse: {
headers: { "Content-Type": MatchersV3.regex('text/plain(;()?charset=(utf|UTF)-8)?', 'text/plain; charset=utf-8') },
},
Artur Neumann
07/05/2022, 3:51 AMMatt (pactflow.io / pact-js / pact-go)
contentType
all together and use the standard header matchingMatt (pactflow.io / pact-js / pact-go)
contentType
definition altogether. We can derive it by other means (extract from headers) and default to JSON otherwise.Matt (pactflow.io / pact-js / pact-go)
Artur Neumann
07/05/2022, 3:53 AMTimothy Jones
07/05/2022, 3:54 AMTimothy Jones
07/05/2022, 3:54 AMTimothy Jones
07/05/2022, 3:54 AMTimothy Jones
07/05/2022, 3:55 AMTimothy Jones
07/05/2022, 3:55 AMMatt (pactflow.io / pact-js / pact-go)
Matchers are still supposed to work in headers, so there’s still a bugArtur wasn’t using it on the headers but an optional
contentType
field on the response object. That doesn’t take a matcher, but the exact content type of the request / responseArtur Neumann
07/05/2022, 3:56 AMMatt (pactflow.io / pact-js / pact-go)
Artur Neumann
07/05/2022, 4:06 AMcontentType
parameter
maybe it was because of this issue https://github.com/pact-foundation/pact-js/issues/575Matt (pactflow.io / pact-js / pact-go)
contentType
- not the header), implicitly via content sniffing in the core, or via the usual header match.Matt (pactflow.io / pact-js / pact-go)
contentType
Artur Neumann
07/05/2022, 4:26 AM"description": "as 'admin', a POST request to create a user",
"request": {
"body": "password=1234&userid=testUser1",
"headers": {
"Content-Type": "application/x-www-form-urlencoded",
"authorization": "Basic YWRtaW46YWRtaW4="
},
......
with .59 it sends me the data as expected
with .60 it converts the body to a JSON string (see wireshark screenshot)