Hi folks, a general matching question. Is it ok to...
# general
s
Hi folks, a general matching question. Is it ok to rely on example value in the e.g.
matching(type, 'whatever'))
expression as a sort-of provider state replacement? (we're using protobuf plugin, but I think this applies to all plugins in general). Context: we have multiple providers that have conventions around values they receive (when running in test mode), similar to stripe test cards So e.g. in our consumer tests we would send something like
"email": "matching(type, '[<mailto:user-exists@example.org|user-exists@example.org>](mailto:<mailto:user-exists@example.org|user-exists@example.org>)')
to make sure the provider returns the response for the "user exists" state. Or should we use
equalTo
matcher instead in this case?
r
I think it is ok, as you set the example value. I try to not rely on the actual values, though. That way they can change without an impact on the tests.
The main issue would be if your test data get's out of sync, you get into a situation where all your tests start failing. This is not just for contract tests, but testing in general.