Hi support, what is the correct way to add the met...
# pact-js
l
Hi support, what is the correct way to add the metadata?
Copy code
1)
      .withMetadata({
        'content-type': 'application/json',
      })

2)
        .withMetadata({
          contentType: 'application/json',
        })
m
The metadata is really up to you, as the keys should match whatever is setup in the verification. You may not need a content type, only match what is relevant for the us case (usually the message headers they are used by the client)
l
Thanks @Matt (pactflow.io / pact-js / pact-go), another question about the Metadata. We had added this on the Pact test and getting verified but seeing metadata is coming as undefined in the Pactflow. Any idea why?
m
You could please share the interaction that’s not showing up? Some versions of languages have the wrong casing, so it’s possible Pactflow is not rendering those. What version of Pact JS are you using?
l
We are using 10.3.1 version
👍 1
t
as unknown as AnyTemplate
should not be required. Are there things that aren't serialisable in your
notifyCustomerContract
? Dates or functions, maybe?
🤔 1
m
Thanks Leon, i’ll take a look on the Pactflow side
l
The test passed with the metadata, we are expecting it to be visible in Pactflow as well but it is undefined
m
Thanks, indeed I suspect their might be a bug in the Pactflow UI. I have raised an item to fix it (there have been some historical differences in the naming of that field, and I’m guessing we rendered the old ones).
Thanks for bringing it to our attention
l
ok, thanks Matt. When do you think the fix will be delivered?
m
I’ll let you know next week Leon.
👍 1
n
@Timothy Jones sorry for the late reply. About`as unknown as AnyTemplate` In this, if i dont do this, i am getting the following error.
t
Right. So that error is “correct”, but unhelpful. I think introducing a
TemplateMap
type might have been a mistake.
You can think of the problem this way - it’s complaining that you’re passing it one of your types instead of an unknown JSON object. Which is right - you’re passing it a
TransformedISOMMessage
.
The “real” situation is that the message content is arbitrary json and not actually a
TransformedISOMMessage
(even though it might be exactly the same shape). However, it’s nice if you can pass the type to Pact, even if it’s not actually what’s really going on. Since then you get compiler complaints if you end up missing elements from a
TransformedISOMMessage
n
ok I will try and let you know.. Thanks @Timothy Jones
t
If it were me, I would leave it as is for now
I’ve played with this a bit - I think a better workaround might be to use the spread operator - like this:
like({...notifyCustomerContract})
👍 1