Hi, I have this problem, when I run the verificati...
# pact-js
l
Hi, I have this problem, when I run the verification provider tests, they seem to be setup with random ports on localhost like so: (this is what I see being executed when I run with debug')
Copy code
pact-node@10.17.2: Starting pact binary '/home/repos/gf-accounts-service/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.88.83/pact/bin/pact-provider-verifier', with arguments [--provider-states-setup-url <http://localhost:46091/_pactSetup> --provider-base-url <http://localhost:46091> --provider-app-version dc04a08
The ports for --provider-states-setup-url and --provider-base-url seem to be failing my TeamCity build sometimes, as some of these ports are reserved, I thought that specifying the providerBaseUrl in the provider settings sets these ports, in my case it was http://localhost:3000/ but it seems like the pact-provider-verifier spins this up with different ports as some proxy? Is there a way to specify which port to use in that pact-provider-verifier script?
m
The pact process spins up a local proxy to enable additional features. The ports you are seeing here are those ports (if you setup debug logging you should see more info on these)
…seem to be failing my TeamCity build sometimes, as some of these ports are reserved
the ports should be selected by the OS as available, so this seems unlikely to me. Can you share the setup that’s failing? Flakey tests are usually a sign of mishandled promises or timeouts (on CI machines often are slower than your high powered dev machine)
👀 1
l
I think I found the problem which you basically pointed me to, so thanks, seems that the state handler which was
Copy code
const stateHandlers = {
      'has a account saved': async () => {
        // connect to local db and add/seed account data
        await seedTable();
        return Promise.resolve(
          'Accounts added: 9ae9b264-f181-46ea-a468-4919c48fbe0(1-5)'
        );
      }
    };
When changing to
Copy code
const stateHandlers = {
      'has a account saved': () => {
        // connect to local db and add/seed account data
        return Promise.resolve(seedTable());
      }
    };
worked, so this means stateHandlers when changing to async would not work, is this intended?
m
hmm no
async
should work
is
seedTable()
a promise/async fn? This does not wait for it to complete, if so.
Copy code
return Promise.resolve(seedTable());
My guess is that the test is timing out and
seedTable
is taking longer than the test timeout
l
Yeah
Copy code
const seedTable = async () => {
  const account = Account.make({
    PK: 'A_' + '9ae9b264-f181-46ea-a468-4919c48fbe01',
    SK: 'V0_' + Account.RECORD_TYPE,
    emailAddress: '<mailto:random@email.com|random@email.com>',
    groupHash: '123',
    siteIdentifier: 'ss',
    idpId: 'random',
    loginCount: 0,
    loginHistory: []
  });
  await account.save();
  const accountTwo = Account.make({
    PK: 'A_' + '9ae9b264-f181-46ea-a468-4919c48fbe02',
    SK: 'V0_' + Account.RECORD_TYPE,
    emailAddress: '<mailto:random@email.com|random@email.com>',
    groupHash: '123',
    siteIdentifier: 'ss',
    idpId: 'random',
    loginCount: 0,
    loginHistory: []
  });
  await accountTwo.save();
}
and I have jest.setTimeout(9000000); so that should be enough time right