for provider side verification, I got ```has statu...
# pact-js
h
for provider side verification, I got
Copy code
has status code 200 (OK)
       includes headers
         "Content-Type" with value "application/json" (OK)
      has a matching body (OK)
then failure
Copy code
1.1) has a matching body
expected 'application/json;charset=utf-8' body but was 'application/json'

1.2) includes header 'Content-Type' with value 'application/json; charset=utf-8'
Expected header 'Content-Type' to have value 'application/json; charset=utf-8' but was 'application/json'
I am little bit confused. lol consumer pact response and request headers are
Copy code
"headers": {
          "Content-Type": "application/json"
        },
m
set logs to
debug
and see if they help understand the issue
what does the contract look like?
h
You can change the log levels using the LOG_LEVEL environment variable.
so is that mean set in provider opt?
m
Ah, that should be a property on the Verifier I think
h
Copy code
logLevel: "DEBUG",
is that right way to set?
m
are you using an IDE? Most IDEs should be able to show you the available types
that looks close, albeit I think the log level is lower case e.g.
debug
h
Types of property 'logLevel' are incompatible.
Type 'string' is not assignable to type 'LogLevel'.
let me try debug
m
t
Type 'string' is not assignable to type 'LogLevel'.
This is because LogLevel isn't a string, it's a type literal. You can address this with
logLevel: 'debug' as const
πŸ‘ 1
h
I found it, actual issue was request failed from provider side lol
Copy code
outgoing response: {"body":"{\"errors\":[{\"message\":\"Not found\",\"extensions\":{\"category\":\"notFound\",\"code\":\"NOT_FOUND\"},\"locations\":[{\"line\":2,\"column\":5}],\"path\":[\"deleteLink\"]}],\"data\":{\"deleteLink\":null}}"
do you know why pact generate this message? is that becuz of empty body? I am not sure others, but it make me really confused lol
Copy code
has a matching body
          expected 'application/json;charset=utf-8' body but was 'application/json'
    1.2) includes header 'Content-Type' with value 'application/json; charset=utf-8'
m
What header is your provider returning?
h
DEBUG pact_verifier::provider_client] Received native response:
"content-type": "application/json"
m
So looks to be missing the charset
h
my consumer contract is
Copy code
"headers": {
          "Content-Type": "application/json"
        }
so it should be fine?
m
Can you please share the whole logs?
h
Failures log?
t
He's asking for the whole log of the test run - often the problem is more easily visible from the whole log rather than just snippets.
☝️ 1
m
Yes, exactly. I can’t tell from above whether it thinks the content type is JSON or it was explicitly told that (via the presence of the
content-type
header)
t
if you could also share the whole contract test, that would be helpful too.
h
I fixed it, it was all about confusion between v2 and v3 providerState mixed up from pactflow, it was my mistake lol haha anyway all good now πŸ™‚
πŸ‘ 1
thanks for your help
debug
was really useful
m
Great to hear you got to the bottom of it!
That sounds like maybe we could improve messaging / DX somewhere. Would you mind please elaborating on the problem a bit further?
h
yeap so the error message (wrong content type
content-type
)was right , because I did not change provider to look at v3, it was look at v2 version but I did not know
so what I did is generate pact v3(consumer) from my local and added tag
test
and publish to pactflow
then go back to provider to look at tag
test
and ran test
human error tbh lol
initially, I manually published from my consumer, and set provider
Copy code
consumerVersionSelectors: [
      { tag: 'feature', latest: true }
I thought provider will look at my latest published pact but it was not
that all started my confusion
so I had to change tag to
test
and find out provider was looking at wrong pact lol
maybe in debug mode, if it shows what consumer version I am looking at it now? it will be much easier to debug?
m
Thanks for the update. So, the verification process should print out which pact it is verifying and why. If you drop the log level back to info, there should be a notice printed out before the verification
πŸ‘ 1
h
thanks Matt
πŸ‘ 1