How to use @pact-foundation/pact-node - 10 common examples

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 pact-foundation / pact-js / src / httpPact.ts View on Github external
private createServer(config: PactOptions) {
    this.server = serviceFactory.createServer({
      consumer: this.opts.consumer,
      cors: this.opts.cors,
      dir: this.opts.dir,
      host: this.opts.host,
      log: this.opts.log,
      pactFileWriteMode: this.opts.pactfileWriteMode,
      port: config.port, // allow to be undefined
      provider: this.opts.provider,
      spec: this.opts.spec,
      ssl: this.opts.ssl,
      sslcert: this.opts.sslcert,
      sslkey: this.opts.sslkey,
    })
  }
}
github lucasmajerowicz / pact-node-example / app / client / spec / PostServiceClient.spec.js View on Github external
describe('Pact', () => {
    let provider;

    // Configure mock server
    const mockServer = wrapper.createServer({
        port: 1234,
        log: path.resolve(process.cwd(), 'logs', 'mockserver-integration.log'),
        dir: path.resolve(process.cwd(), 'pacts'),
        spec: 2
    });

    // Define expected payloads
    const expectedBodyPostList = {
        posts: [
            {id: 1, date: '01/10/2016', contents: 'Bla bla bla'},
            {id: 2, date: '01/09/2016', contents: 'Microservice microservice'}
        ]
    };

    const expectedBodyPostGet = {
        post: {id: 1, date: '01/08/2016', contents: 'Bla'}
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 kyle-ssg / nextjs-redux / tests / pact / helpers / pact.publish.js View on Github external
const pact = require('@pact-foundation/pact-node');
const path = require('path');

require('dotenv').config();

if (process.env.PACT_BROKER) {
    const opts = {
        pactFilesOrDirs: [path.resolve(__dirname, `../../../pacts/${namespace}.json`)],
        pactBroker: process.env.PACT_BROKER,
        pactBrokerUsername: process.env.PACT_BROKER_USERNAME,
        pactBrokerPassword: process.env.PACT_BROKER_PASSWORD,
        tags: ['prod', 'test'],
        consumerVersion: `${process.env.CI_COMMIT_REF_NAME || 'local'}.${Math.floor(new Date() / 1000)}`,
    };

    pact.publishPacts(opts)
        .then(() => {
        })
        .catch(() => {
        });
} else {
    console.log('Skipping pact publish, no PACT_BROKER env variable found!');
}
github pact-foundation / pact-js-mocha / test / specHelper.js View on Github external
'use strict'

var path = require('path')
var wrapper = require('@pact-foundation/pact-node')

var mockServer = wrapper.createServer({
  port: 1234,
  log: path.resolve(process.cwd(), 'logs', 'mockserver-ui.log'),
  dir: path.resolve(process.cwd(), 'pacts'),
  spec: 2
})

mockServer.start().then(function () {
  run()

  process.on('SIGINT', function () {
    wrapper.removeAllServers()
  })
})
github pact-foundation / pact-js / test / dsl / integration_default_port.spec.js View on Github external
describe('Pact default Port', () => {

  const MOCK_PORT = 1234
  const PORT = Math.floor(Math.random() * 999) + 9000
  const PROVIDER_URL = `http://localhost:${PORT}`
  const mockServer = wrapper.createServer({
    port: MOCK_PORT,
    log: path.resolve(process.cwd(), 'logs', 'mockserver-integration.log'),
    dir: path.resolve(process.cwd(), 'pacts'),
    spec: 2
  })
  const interceptor = new Interceptor(`http://localhost:${MOCK_PORT}`)
  const EXPECTED_BODY = [{
    id: 1,
    name: 'Project 1',
    due: '2016-02-11T09:46:56.023Z',
    tasks: [
      {id: 1, name: 'Do the laundry', 'done': true},
      {id: 2, name: 'Do the dishes', 'done': false},
      {id: 3, name: 'Do the backyard', 'done': false},
      {id: 4, name: 'Do nothing', 'done': false}
    ]
github pact-foundation / pact-js-mocha / test / specHelper.js View on Github external
process.on('SIGINT', function () {
    wrapper.removeAllServers()
  })
})
github pact-foundation / pact-js / test / helper.ts View on Github external
process.on("SIGINT", () => {
  pact.removeAllServers()
})
github alphagov / pay-selfservice / test / test_helpers / pact_proxy.js View on Github external
removeAll: function () {
    return wrapper.removeAllServers()
  }
}

@pact-foundation/pact-node

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

MIT
Latest version published 8 months ago

Package Health Score

74 / 100
Full package analysis