Good morning. I'm using `"@pact-foundation/pact": ...
# pact-js
c
Good morning. I'm using
"@pact-foundation/pact": "^12.4.0",
and in the process of sharing an example to get help with my NextJS thread above, I found that if I add
pactUrls
(pointing to valid local files) and remove
pactBrokerUrl
,
pactBrokerUsername
,
pactBrokerPassword
and
publishVerificationResult
from
verifierOpts
then when run provider verification pact attempts to call state change handlers at
<http://127.0.0.1>:(RANDOM_PORT)/_pactSetup
even though
providerStatesSetupUrl
has never been set up. Also, there is no state defined in the pacts themselves. This appears broken and I'm not sure how to share the NextJS demo project if I cannot package pacts with it.
đź‘‹ 1
Working
verifierOpts
, pointing at a self-hosted broker:
Copy code
{
  providerBaseUrl: '<http://localhost:3030>',
  provider: "Chris' scratch NextJS App",
  pactBrokerUrl: '<https://REDACTED>',
  consumerVersionSelectors: [
    { mainBranch: true },
    { matchingBranch: true },
    { deployedOrReleased: true }
  ],
  publishVerificationResult: false,
  providerVersion: '0.1.0+e4b3c96',
  providerVersionTags: [ 'main' ],
  providerVersionBranch: 'main',
  pactBrokerUsername: 'REDACTED',
  pactBrokerPassword: 'REDACTED',
  enablePending: true,
  includeWipPactsSince: '2024-01-01'
}
Broken
verifierOpts
, pointing at a local file:
Copy code
{
  providerBaseUrl: '<http://localhost:3030>',
  provider: "Chris' scratch NextJS App",
  pactUrls: [
  '/home/chris/src/nextjs-scratch/my-app/pacts/Fauxclient-Scratch NextJS Fullstack App.json'
  ],
  consumerVersionSelectors: [
    { mainBranch: true },
    { matchingBranch: true },
    { deployedOrReleased: true }
  ],
  providerVersion: '0.1.0+e4b3c96',
  providerVersionTags: [ 'main' ],
  providerVersionBranch: 'main',
  enablePending: true,
  includeWipPactsSince: '2024-01-01'
}
m
when run provider verification pact attempts to call state change handlers at
<http://127.0.0.1>:(RANDOM_PORT)/_pactSetup
even though
providerStatesSetupUrl
has never been set up
that’s an internal proxy that Pact sets up.
Also, there is no state defined in the pacts themselves. This appears broken and I’m not sure how to share the NextJS demo project if I cannot package pacts with it.
the state handler is called every time, even if empty (this allows other hooks to run). It shouldn’t cause errors in and of itself. What’s the actual problem you’re seeing?
c
Attached is the logs. You can see near the top are the verifierOpts. In addition to comments about _pactSetup call, you can see it referring to pacts on a broker, even though no broker settings have been passed in?
m
Thanks
By any chance do you have
PACT_BROKER_BASE_URL
or any environment variables like that that? They could be being picked up and used to fetch dynamically also
I’m happy to look at the test repo and debug with you, and if necessary, improve the logging in Pact JS to make it easier for next time
y
can you try with all options below pactUrls removed, they aren’t relevant for your mode of verification
or don’t set them if you have a pact url set