<#846 VerifyProvider method always return failure ...
# pact-js-development
g
#846 VerifyProvider method always return failure test although all the interactions have passed Issue created by erickbelfy Software versions Please provide at least OS and version of pact-jsOS: Mac OSX 11.6.2_ • Consumer Pact library: @pact-foundation/pact ^9.17.3 • Provider Pact library: no clue • Node Version:
v16.11.1
Issue Checklist Please confirm the following: ☑︎ I have upgraded to the latest ☑︎ I have the read the FAQs in the Readme ☑︎ I have triple checked, that there are no unhandled promises in my code and have read the section on intermittent test failures ☑︎ I have set my log level to debug and attached a log file showing the complete request/response cycle ☐ For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem Expected behaviour once all the interactions have passed we expect that the tests will also be successful Actual behaviour I'm having the following error
Copy code
FAIL src/api.pact.ts (6.691 s)
  Pact Verification
    ✕ validates the expectations of SignupService (5005 ms)

  ● Pact Verification › validates the expectations of SignupService

    thrown: "Exceeded timeout of 5000 ms for a test.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

      25 | describe('Pact Verification', () => {
      26 |   // eslint-disable-next-line jest/expect-expect
    > 27 |   it('validates the expectations of SignupService', () => {
         |   ^
      28 |     const opts: VerifierOptions = {
      29 |       logLevel: 'debug',
      30 |       providerVersionTags: ['test'],

      at src/api.pact.ts:27:3
      at Object.<anonymous> (src/api.pact.ts:25:1)
      at TestScheduler.scheduleTests (../../node_modules/@jest/core/build/TestScheduler.js:333:13)
      at runJest (../../node_modules/@jest/core/build/runJest.js:404:19)
      at _run10000 (../../node_modules/@jest/core/build/cli/index.js:320:7)
      at runCLI (../../node_modules/@jest/core/build/cli/index.js:173:3)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        6.757 s, estimated 8 s
Steps to reproduce with a given file
Copy code
/* istanbul ignore file */
// eslint-disable-next-line import/no-extraneous-dependencies
import { Verifier, VerifierOptions } from '@pact-foundation/pact';
import express from 'express';
import signupRoutes from './routes/api/signup-routes';
import SignupService from './services/signup';

const newAccount = {
  accountUuid: 'blah',
  realm: 'blah',
  userUuid: 'blah',
  groupIds: ['271b6c14-9334-11ec-b909-0242ac120002', 'f325425c-9330-11ec-b909-0242ac120002'],
};

const port = 8080;

// Setup provider server to verify
const app = express();
app.use(express.json());
app.use('/api', signupRoutes);

const server = app.listen(port);

describe('Pact Verification', () => {
  // eslint-disable-next-line jest/expect-expect
  it('validates the expectations of SignupService', () => {
    const opts: VerifierOptions = {
      logLevel: 'debug',
      providerVersionTags: ['test'],
      providerBaseUrl: `<http://localhost:${port}>`,
      provider: 'PlatformSignupServer',
      providerVersion: '1.0.0',
      pactBrokerUrl: '<http://localhost:9292/>',

      stateHandlers: {
        'user doesnt exist in the database': () => {
          jest.spyOn(SignupService.prototype, 'createAccount').mockResolvedValueOnce(newAccount);
          return Promise.resolve(newAccount);
        },
      },
    };
    if (<http://process.env.CI|process.env.CI>) {
      Object.assign(opts, {
        publishVerificationResult: true,
      });
    }

    return new Verifier(opts)
      .verifyProvider()
      .then((output) => {
        console.log(output);
      })
      .finally(() => {
        server.close();
      });
  });
});
the result of the test is always a failure even though the interactions are passing. Relevant log files Please ensure you set logging to
DEBUG
and attach any relevant log files here (or link to a gist).
``` $ NODE_TLS_REJECT_UNAUTHORIZED=0 API_HOSTNAME=internal-customer-signup-service-mytzud-578406012.us-east-1.elb.amazonaws.com API_PROTOCOL=https CI=true yarn test src/api.pact.ts --testMatch \"**/*.pact.ts\" $ jest --runInBand src/api.pact.ts --testMatch '"**/*.pact.ts"' [2022-03-28 203204.062 +0000] INFO (77810 on MAC-CA-BELFOER2): pact@9.17.3: Verifying provider [2022-03-28 203204.062 +0000] INFO (77810 on MAC-CA-BELFOER2): pact@9.17.3: debug request/response logging enabled [2022-03-28 203204.062 +0000] INFO (77810 on MAC-CA-BELFOER2): pact-node@10.17.2: Verifying Pacts. [2022-03-28 203204.062 +0000] INFO (77810 on MAC-CA-BELFOER2): pact-node@10.17.2: Verifying Pact Files [2022-03-28 203204.062 +0000] DEBUG (77810 on MAC-CA-BELFOER2): pact-node@10.17.2: Starting pact binary '/Users/belfoer1/Documents/platform/signup/node_modules/@pact-foundation/pact-node/standalone/darwin-1.88.83/pact/bin/pact-provider-verifier', with arguments [--provider-states-setup-url http://localhost:54256/_pactSetup --log-level debug --provider-version-tag test --provider-base-url http://localhost:54256 --provider PlatformSignupServer --provider-app-version 1.0.0 --pact-broker-base-url http://localhost:9292/ --publish-verification-results true --verbose true] [2022-03-28 203204.062 +0000] DEBUG (77810 on MAC-CA-BELFOER2): pact-node@10.17.2: Created '/Users/belfoer1/Documents/platform/signup/node_modules/@pact-foundation/pact-node/standalone/darwin-1.88.83/pact/bin/pact-provider-verifier' process with PID: 77930 [2022-03-28 203204.062 +0000] DEBUG (77810 on MAC-CA-BELFOER2): pact-node@10.17.2: opening connection to localhost:9292... opened <- "GET / HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: application/hal+json\r\nUser-Agent: Ruby\r\nHost: localhost:9292\r\n\r\n" -> "HTTP/1.1 200 OK\r\n" -> "Vary: Accept\r\n" -> "Content-Type: application/hal+json;charset=utf-8\r\n" -> "Date: Mon, 28 Mar 2022 203205 GMT\r\n" -> "Server: Webmachine-Ruby/1.6.0 Rack/1.3\r\n" -> "X-Pact-Broker-Version: 2.89.1\r\n" -> "X-Content-Type-Options: nosniff\r\n" -> "Content-Length: 4300\r\n" -> "\r\n" reading 4300 bytes... -> "{\"_links\":{\"self\":{\"href\":\"http://localhost:9292\",\"title\":\"Index\",\"templated\":false},\"pb:publish-pact\":{\"href\":\"http://localhost:9292/pacts/provider/{provider}/consumer/{consumer}/version/{consumerApplicationVersion}\",\"title\":\"Publish a pact\",\"templated\":true},\"pb:publish-contracts\":{\"href\":\"http://localhost:9292/contracts/publish\",\"title\":\"Publish contracts\",\"templated\":false},\"pb:latest-pact-versions\":{\"href\":\"http://localhost:9292/pacts/latest\",\"title\":\"Latest pact versions\",\"templated\":false},\"pb:tagged-pact-versions\":{\"href\":\"http://localhost:9292/pacts/provider/{provider}/consumer/{consumer}/tag/{tag}\",\"title\":\"All versions of a pact for a given consumer, provider and consumer version tag\",\"templated\":false},\"pb:pacticipants\":{\"href\":\"http://localhost:9292/pacticipants\",\"title\":\"Pacticipants\",\"templated\":false},\"pb:pacticipant\":{\"href\":\"http://localhost:9292/pacticipants/{pacticipant}\",\"title\":\"Fetch pacticipant by name\",\"templated\":true},\"pb:latest-provider-pacts\":{\"href\":\"http://localhost:9292/pacts/provider/{provider}/latest\",\"title\":\"Latest pacts by provider\",\"templated\":true},\"pb:latest-provider-pacts-with-tag\":{\"href\":\"http://localhost:9292/pacts/provider/{provider}/latest/{tag}\",\"title\":\"Latest pacts for provider with the specified tag\",\"templated\":true},\"pb:provider-pacts-with-tag\":{\"href\":\"http://localhost:9292/pacts/provider/{provider}/tag/{tag}\",\"title\":\"All pact versions for the provider with the specified consumer version tag\",\"templated\":true},\"pb:provider-pa… pact-foundation/pact-js