Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provider v3 drops state params in Pact file with spec v2 #1079

Open
5 tasks done
martinslota opened this issue Mar 28, 2023 · 5 comments
Open
5 tasks done

Provider v3 drops state params in Pact file with spec v2 #1079

martinslota opened this issue Mar 28, 2023 · 5 comments
Labels
enhancement Indicates new feature requests help wanted Indicates that a maintainer wants help on an issue or pull request

Comments

@martinslota
Copy link

Software versions

  • OS: Mac OS 13.2.1
  • Consumer Pact library: PactJS v 11.0.2
  • Provider Pact library: N/A
  • Node Version: v18.15.0

Issue Checklist

Please confirm the following:

  • I have upgraded to the latest
  • I have the read the FAQs in the Readme
  • I have triple checked, that there are no unhandled promises in my code and have read the section on intermittent test failures
  • I have set my log level to debug and attached a log file showing the complete request/response cycle
  • For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem

Expected behaviour

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.

Actual behaviour

Only the description of the first state is copied into the providerState field for each interaction.

Steps to reproduce

See https://github.com/martinslota/pact-js-bug-state-params-dropped.

Relevant files

@martinslota martinslota added the bug Indicates an unexpected problem or unintended behavior label Mar 28, 2023
@TimothyJones
Copy link
Contributor

TimothyJones commented Mar 28, 2023

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.

@mefellows
Copy link
Member

That's correct. Perhaps we shouldn't allow it in the DSL

@martinslota
Copy link
Author

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.

@martinslota
Copy link
Author

That's correct. Perhaps we shouldn't allow it in the DSL

That would be a very nice touch! 💯

@mefellows
Copy link
Member

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.

@mefellows mefellows added enhancement and removed bug Indicates an unexpected problem or unintended behavior labels Mar 29, 2023
@mefellows mefellows added help wanted Indicates that a maintainer wants help on an issue or pull request enhancement Indicates new feature requests labels Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates new feature requests help wanted Indicates that a maintainer wants help on an issue or pull request
Projects
Status: New Issue
Development

No branches or pull requests

3 participants