Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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,
})
}
}
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'}
'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)
})
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!');
}
'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()
})
})
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}
]
process.on('SIGINT', function () {
wrapper.removeAllServers()
})
})
after(() => {
wrapper.removeAllServers()
})
process.on("SIGINT", () => {
pact.removeAllServers()
})
removeAll: function () {
return wrapper.removeAllServers()
}
}