How to use the @pact-foundation/pact-node.verifyPacts function in @pact-foundation/pact-node

To help you get started, we’ve selected a few @pact-foundation/pact-node examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RisingStack / training-microservices-v2 / 8_contract_testing / server / consumerTests / verifyPacts.js View on Github external
'use strict'

const pact = require('@pact-foundation/pact-node')
const path = require('path')
require('./testSitesService')

const opts = {
  providerBaseUrl: 'http://localhost:3001',
  providerStatesSetupUrl: 'http://localhost:3001/test/setup',
  pactUrls: [path.resolve(__dirname, '../../pacts/client-siteservice.json')]
}

pact.verifyPacts(opts).then(() => {
  console.log('success')
  process.exit(0)
}).catch((error) => {
  console.log('failed', error)
  process.exit(1)
})
github lucasmajerowicz / pact-node-example / app / service / spec / PostService.spec.js View on Github external
var pact = require('@pact-foundation/pact-node');
var path = require('path');
const PostService = require('../PostService');

var opts = {
    providerBaseUrl: 'http://localhost:8081',
    providerStatesUrl: 'http://localhost:8081/states',
    providerStatesSetupUrl: 'http://localhost:8081/setup',
    pactUrls: [path.resolve(__dirname, '../../../pacts/my_consumer-posts_provider.json')]
};

pact.verifyPacts(opts).then(() => {
    console.log('success');
    process.exit(0);
}).catch((error) => {
    console.log('failed', error);
    process.exit(1);
});
github pact-foundation / pact-js / src / messageProviderPact.ts View on Github external
return (server: http.Server) => {
      const opts = {
        ...omit(this.config, "handlers"),
        ...{ providerBaseUrl: "http://localhost:" + server.address().port },
      } as VerifierOptions

      return qToPromise(serviceFactory.verifyPacts(opts))
    }
  }
github pact-foundation / pact-js / src / dsl / verifier.ts View on Github external
return (server: http.Server) => {
      const opts = {
        providerStatesSetupUrl: `${this.address}:${server.address().port}${
          this.stateSetupPath
        }`,
        ...omit(this.config, "handlers"),
        providerBaseUrl: `${this.address}:${server.address().port}`,
      }

      return qToPromise(pact.verifyPacts(opts))
    }
  }
github pact-foundation / pact-js-mocha / src / index.js View on Github external
var test = new Test('should honour interactions', function (done) {
        wrapper.verifyPacts(opts)
          .then(function (data) {
            fn(data, done)
          })
          .catch(function (err) {
            done(err)
          })
      })
github kununu / pact-cli / src / commands.js View on Github external
const toValidate = validUrl.isUri(args.PACT_FILE) ? args.PACT_FILE : path.resolve(process.cwd(), args.PACT_FILE);

  const opts = {
    pactUrls: [toValidate],
    providerBaseUrl: args.provider_base_url,
    providerStatesSetupUrl: args.states_setup_url,
  };

  if (config.brokerUser.trim() !== '') {
    Object.assign(opts, {
      pactBrokerUsername: config.brokerUser,
      pactBrokerPassword: config.brokerPassword,
    });
  }

  pact.verifyPacts(opts).then((pactObject) => {
    log('=================================================================================');
    log(`Pact ${args.PACT_FILE} verified with following result`);
    log('=================================================================================');
    log(JSON.stringify(pactObject, null, 2));
    log('=================================================================================');
  }, (err) => log(`Verify failed because of \n${err}`));
}

@pact-foundation/pact-node

Core of @pact-foundation/pact. You almost certainly don't want to depend on this directly.

MIT
Latest version published 10 months ago

Package Health Score

74 / 100
Full package analysis