Is there a way to optionally match on something wi...
# pact-js
v
Is there a way to optionally match on something with V3/V4? In other words, I want to see if a value is either null or a specific type - like
null
or
integer
v
This seems like a pretty common scenario though, doesn't it?
y
if you have everything as optional essentially, your server could return nothing and would happily pass verification, so you are suggested to do it with provider states and have explicit tests for each case you want to cover
v
> your server could return nothing and would happily pass verification your server still has to return the
key
though. If it doesn't do that, the contract would be broken
y
covered in the above link
The same goes for specifying “SOME_VALUE or null”. If all your provider verification test data returned nulls for this key, you might think that you had validated the “SOME_VALUE”, but in fact, you never had. You could get a completely different “SOME_VALUE” for this key in production, which may then cause issues.
v
thinking2
thanks for the info! thankyou