Hi there folks, new to Pact here and I'm integrati...
# pact-broker
k
Hi there folks, new to Pact here and I'm integrating it into an Angular app. I've got an issue with the generated pact file's meta data section:
Copy code
"metadata": {
    "pactSpecification": {
      "version": "2.0.0"
    }
  }
I somehow need to configure this version number to be version 3.0.0 to meet the requirements of the provider's contract. How can I configure this?
y
Hey the specification is defined by the client library, when the pact is generated. When you say provider contract, what are you referring to? Which pact client library are you using on your provider side for performing your pact verifications?
m
Yes that seems strange. If a provider can support spec 3 pacts it can also verify a spec 2 pact.
k
When you say provider contract, what are you referring to?
I’m referring to the platform APIs pact file that will be in contract with our Angular frontend pact file
which pact client library
if you are referring to the node module, this is our dependency in package-lock.json:
Copy code
"@pact-foundation/pact-node": "^10.17.2",
and
npm ls
shows both:
@pact_foundation_greet/pact@9.18.1
and
jest-pact@0.9.4
m
Thanks
I somehow need to configure this version number to be version 3.0.0 to meet the requirements of the provider’s contract. How can I configure this?
what makes you think this is true? Are you seeing some error or problem?
k
That is a great question. I was told by the platform team that was the issue so I’m going to follow up with them. Looking at the diff between the placeholder consumer pact file platform team has versus the consumer pact file my frontend created yields a lot of differences in the matchingRules sections
the platform team cites the main issue with the version differences being the addition of params within the providerStates section does not seem to be supported by 2.0.0
y
why are you diffing the consumer pact files? I assume there are two consumers here, one generating a
2.0.0
spec file, and one generating a
3.0.0
file? the issue is with the team verifying the contracts (provider side?)
k
I’m diffing the two consumer pact files so I can look for differences. The placeholder consumer pactfile that the platform team has currently published is working, but the version that the actual consumer (my angular app) is generating is causing errors in pactflow. The provider pactfile has remained the same throughout
y
Your provider shouldn't have a pact file, assuming you are using regular consumer-driven contract testing. your consumer pact files should be verified by provider, and return a verification result. depending on the pact library used in your provider will determine which pact specification versions it can support.
k
There is only one consumer, which is an angular app. There are two consumer pactfiles however because the platform team created a placeholder for their API temporarily
y
so a single consumer app, is generating two pact files, with two different specifications. is that causing an issue to your provider team for verifying? which language are they using to verify the pact files. Which language are you using to create the pact files? Pact-JS? Is one of the tests using the PactJS V3 interface (thusly generating v3 spec pact files)
I'm still not sure I understand the root of the problem here, however if you simply want to generate a v3 pact file, from pact-js, which you are using in your angular app, you will need to use the
PactV3
interface from
pact-js
https://github.com/pact-foundation/pact-js/blob/master/docs/consumer.md#consumer-package something like
Copy code
const provider = new PactV3({
  dir: path.resolve(process.cwd(), 'pacts'),
  consumer: 'MyConsumer',
  provider: 'MyProvider',
});
the
Pact
interface will provide up to
v2.0.0
and remains for backwards compatability. You will need
pact-js
v10+
k
so a single consumer app, is generating two pact files, with two different specifications.
The consumer app is only generating a single pact file that is spec version 2.0.0
is that causing an issue to your provider team for verifying? which language are they using to verify the pact files
Provider team is using .NET to verify. They are expecting spec version 3.0.0
Which language are you using to create the pact files? Pact-JS? I
We have
@pact_foundation/pact
as a dependency and
@jest/pact
. Is
pact-js
a separate package?
Is one of the tests using the PactJS V3 interface (thusly generating v3 spec pact files)
I’ve just upgraded to pact 11.0.0 so I can use the V3 interface. There seems to be a lot of differences I’m going over right now
y
thanks, that is a bit clearer. pact-net v4 should support pact spec versions v2/v3 https://github.com/pact-foundation/pact-net#pact-specification which lines up with Matts comment
Yes that seems strange. If a provider can support spec 3 pacts it can also verify a spec 2 pact.
what is the issue the provider is seeing when attempting to verify your v2 pact.
k
what is the issue the provider is seeing when attempting to verify your v2 pact
I’ll let you know and reach out ASAP. In the mean time, is there some documentation on how to work with V3? It seems I no longer have access to mockService, setup(), verify(), finalize() within a PactV3, and addInteraction takes different parameters
I’m also still curious about this:
We have
@pact_foundation/pact
as a dependency and
@jest/pact
. Is
pact-js
a separate package?
y
pact-js project is published as a package
@pact-foundation/pact
jest-pact
is a convenience wrapper mainly to deal with the setup/teardown lifecycle methods that were required before when pact-js used a ruby core. you pact use
@pact-foundation/pact
directly or use
jest-pact
on top. migration guide for v3 format https://github.com/pact-foundation/pact-js/blob/master/docs/migrations/9-10.md
k
Now that mockProvider (PactV3) no longer has access to mockService in v3, where can I access the baseUrl? The migration docs claim this:
Copy code
the mockService property on the Pact class is no longer an actual MockService, but supports the baseUrl property for compatibility.
But I am seeing an error that mockService is not a known property of PactV3
message has been deleted