Hello there! Consumer Messaging Pact Test failing...
# pactflow
r
Hello there! Consumer Messaging Pact Test failing with below error "Expected property Date with a length of 24, but has a length of 20, differs near Z" what's observed is... failing only when the date milliseconds are all zeros such as... "2023-10-31T063424.000Z"
đź‘‹ 1
m
We're going to need a lot more detail I'm afraid.
Howtoask and howtorepro are good starting points
r
Hi Matt, Thanks for the reply, please find the attached screenshot for complete detailed code which is erroring out...
m
This is a problem with your .NET code. Clearly, you are passing in the same value on line 46 and line 53, so that implies that
TestOrder
is truncating what you are giving to it
p
@Matt (pactflow.io / pact-js / pact-go) Basically after Json serialization, the trailing insignificant 0's are removed. In the mocked data, we have mentioned those 0s. Hence there is a length difference causing pact test cases to fail with the error : "Expected property Date with a length of 24, but has a length of 20, differs near Z" Can you suggest some insights to this issue without removing those 0's from our mock data?
m
This is really a unit testing question with .NET, and not related to Pact
Your code / tooling / frameworks used for serialising and deserialising data (line 53) is comparing to a standard JSON blob (line 46). The line 46 code doesn’t know to zero out the data.
i.e. your test assertion is a bad one. This has nothing to do with Pact. The problem is a useless assertion, probably because you’re just trying to setup a demo to show a basic workflow?
Presumably, you could fix it by removing the extra 00's on line 46