Bhoomtawath Plinsut
01/23/2025, 8:30 AMJoshua Ellis
01/23/2025, 11:15 PM420 is unknown and 69 is know; and then in the second case, there should be another that sets up the provider in a state where 420 is unknown.
It's generally a good idea to coordinate between consumers and providers which states are handled for consistency. In this case, you would have two parametrised states:
1. given a product exists with an id parameter (and maybe additional parameters)
2. given a product does not exist with an id parameter.Bhoomtawath Plinsut
01/24/2025, 3:58 AMStanislav Vodetskyi
01/27/2025, 8:07 PMBoris
01/28/2025, 2:50 AMBoris
01/28/2025, 2:53 AMStanislav Vodetskyi
01/28/2025, 5:08 AMStanislav Vodetskyi
01/28/2025, 5:09 AMMatt (pactflow.io / pact-js / pact-go)
I found another tool. https://github.com/pactflow/swagger-mock-validator
This is not ideal, but probably could fill early adoption.
It can compare a pact file against a swagger schema. So, no need to set up a mocked behavior.so this tool is part of a wider āschema validationā approach to contract testing. Itās incorporated into our (PactFlowās) bi-directional contract testing feature. Itās worth noting the trade-offs of this approach, although it is definitely aimed at reducing the barrier to entry (in particular when you already have good existing test coverage - see the primary use cases) Please also note that we are re-writing this tool for performance, code readability etc. but itās stable enough to use. You would still need to integrate it into your workflow, unless you use PactFlow in which case this is all run in our cloud environment.
Boris
01/28/2025, 5:13 AMBoris
01/28/2025, 5:14 AMMatt (pactflow.io / pact-js / pact-go)
We sometimes use provider states, but we found itās easier for provider to specify a set of known defaults for all consumers to use in their tests, similar to stripe test cards: https://docs.stripe.com/testing#cardsas for your comment Stan, I often advocate for a similar approach to customers with lots of consumers who have identified it as problematic for them. It is one of the areas of Pact that has some usability/scale challenges, because it does require higher collaboration.
Not sure about consumer-namespaced states, I donāt think Iāve heard of that before . . .Actually the creator of provider states (Beth) advocated for this, but I donāt think pretty much anybody has followed that advice š . Iāll see if I can find it
Matt (pactflow.io / pact-js / pact-go)
given in a BDD (i.e. what I describe here: https://docs.pact.io/getting_started/provider_states)
This makes the tests more readable/comprehensible.
I also think there is a role for the Pact Broker to play here, to make these states more visible to other/new consumers. Itās something that we discussed in the new UX for PactFlow but didnāt quite make the scoping cutBoris
01/28/2025, 5:32 AMBeth advocated for this, but I donāt think pretty much anybody has followed that adviceI feel like I've heard that a few times joyfacepalm
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)