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

Feature Request - eachLike(itemDescriptionWithMatchers, exampleArray?) #101

Open
2 tasks done
hborham opened this issue Sep 30, 2022 · 4 comments
Open
2 tasks done

Comments

@hborham
Copy link

hborham commented Sep 30, 2022

Checklist

This checklist is optional, but studies show that people who have followed it checklist are really excellent people and we like them 🤣

Before making a feature request, I have:

Feature description

Please describe what you would like Pact-js to do

Extended support for matching arrays with an optional example parameter, such as:

eachLike(itemDescriptionWithMatchers, exampleArray?)
atLeastOneLike(matcher, exampleArray?)` 

Use case

What is the use case that motivates this feature request?
Reuse of pacts for consumer development/testing while utilizing the pact-stub-server
Please describe why you would like Pact-js to have this feature.

We have a consumer (react ui) pact we would like to reuse as a stub response within a real network request by loading our pacts into thepactfoundation/pact-stub-server. This benefits us in two specific ways:

  1. We're able to reuse our pacts for a small set of integration tests with the provider apis
  2. We're able to reuse our pacts for local development purposes of react ui and not be connected to a provider backend.

Our goal is to generate a realistic response to reuse during development/testing and also be minimalistic for the provider to verify, eg atLeastOneLike.

Request for matcher(s) to support eachLike(matcher, exampleArray?), atLeastOneLike(matcher, exampleArray?) so that the generated stub response for the consumer definition is:

{
    picklists: [
      {id: 1, name: 'She/Her'},
      {id: 2, name: 'He/Him'},
      {id: 3, name: 'They/Them'},
      {id: 4, name: 'Other'},
    ]
}

and the generated matcher for the provider is:

"matchingRules": {
    "body": {
      "$": {
        "combine": "AND",
        "matchers": [
          {
            "match": "type"
          }
        ]
      },
      "$.picklists": {
        "combine": "AND",
        "matchers": [
          {
            "match": "type",
            "min": 1
          }
        ]
      }
    },
}

Additional discussion here pact-foundation.slack.com/#general

@mefellows
Copy link
Member

Thanks for this!

@hborham
Copy link
Author

hborham commented Dec 5, 2022

@mefellows would you happen to know if this feature request is a candidate for https://github.com/pact-foundation/pact-js/labels/good%20first%20issue

It would make my life easier, so I was wondering if I could tackle this feature.

@mefellows
Copy link
Member

I don't think it is Haz, as this will require a framework-wide change. @uglyog @bethesque any thoughts on this?

Should this migrate to the Pact Spec project?

@bethesque
Copy link
Member

This is a pact-spec change.

@mefellows mefellows transferred this issue from pact-foundation/pact-js Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants