Open martinslota opened 1 year ago
When using the v3 Pact provider with spec version 2, state parameters (as well as multiple states) should be present in the providerState field of interactions in the generated Pact file.
I don't think this is the expected behaviour. Pact spec version 2 does not support state parameters or multiple states.
That's correct. Perhaps we shouldn't allow it in the DSL
I don't think this is the expected behaviour. Pact spec version 2 does not support state parameters or multiple states.
That's a good point.
The bug report originates from my effort to upgrade from @pact-foundation/pact
version 9. The original code put an entire stringified JSON array into the state
field of an interaction. I guess I expected that if I upgrade and put the original data into states
, it bubbles all the way to the providerState
field in the resulting pact file.
I suppose I could in principle put the stringified array into the description
field of the first element of an interaction's states
field and I'd get the effect I want.
As far as I'm concerned, we can close this bug report.
That's correct. Perhaps we shouldn't allow it in the DSL
That would be a very nice touch! 💯
In the V4 interface, the API itself doesn't allow incompatible things to be done like this. It's a bit harder to do with the V3 API because we allow the spec as an option in the constructor and that changes what can/can't be done later in the API, making the checks complicated/messy.
I'll leave it open for now as a potential enhancement.
Software versions
Issue Checklist
Please confirm the following:
Expected behaviour
When using the
v3
Pact provider with spec version 2, state parameters (as well as multiple states) should be present in theproviderState
field of interactions in the generated Pact file.Actual behaviour
Only the
description
of the first state is copied into theproviderState
field for each interaction.Steps to reproduce
See https://github.com/martinslota/pact-js-bug-state-params-dropped.
Relevant files