Hi everyone! Is there any possibility to set given...
# pact-js
d
Hi everyone! Is there any possibility to set given section (provider state) multiple time (multiple provider states)? I tried to use V3 version but it's not implemented there. Could anyone help me with that? It's really very let's say critical thing for us.
b
Even if it's a kludge (for now?) you should be able to implement reusable provider state, based on the state string (if that's all you have available). The most structured pre-state*s* thing I've seen is a known format for the state string, which can be parsed out on the provider side, e.g.
"state A, state B, state C"
which becomes
['state A', 'state B', 'state C']
, then you can manually trigger those states. Not ideal, but the closest I've seen if you don't have library support.
a
I've used simply the word
and
myself to split my V2 state string into multiple separate states, which are applied simultaneously. Not ideal as well, but at least it has worked great. I also added a separate
clean
(default:
true
) option in the request to specify whether the database is dropped before the requested state is applied. So I can sequentially apply states in non-Pact tests (integration, e2e).
👍 1