pact-specification
pact-specification copied to clipboard
Feature Request - eachLike(itemDescriptionWithMatchers, exampleArray?)
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:
- [x] Searched the issues to check that this feature hasn't been requested before
- [x] Checked the documentation to see if it is possible to do what I want already
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:
- We're able to reuse our pacts for a small set of integration tests with the provider apis
- 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
Thanks for this!
@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.
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?
This is a pact-spec change.