Pact-broker-extensions is handy package that would let you speak to your pact-broker instance through nodejs for CI purposes.
pact-broker-extension will fit in to CI story irrespective of the application technology being used.
I want to verify my pact consumer contracts on build agent
I want to sync the pact consumer contracts generated on my build agent to pact broker
npm install pactbroker-extn
Here is an sample travis yaml snippet,
before_script:
- npm install && node ./getProviderPacts.js
script:
- ./run-test.sh
after_script:
- npm install && node ./saveConsumerPacts.js
deploy:
provider: ...
Sample code for getProviderPacts.js (Code link)
var pactbroker = require('pactbroker-extn');
var nconf = require('nconf');
nconf.argv().env();
var pact_broker_config = {
baseUri: 'http://pactbroker.com/',
username: nconf.get('pact_broker_user'),
password: nconf.get('pact_broker_password'),
providerFolderPath: "../pacts/provider/"
};
pactbroker.getPactsForProvider("forms-api", pact_broker_config);
Sample code for saveConsumerPacts.js (code link)
var pactbroker = require('pactbroker-extn');
var nconf = require('nconf');
nconf.argv().env();
var pact_broker_config = {
baseUri: 'http://pactbroker.com/',
username: nconf.get('pact_broker_user'),
password: nconf.get('pact_broker_password'),
consumerFolderPath: './testdata',
};
pactbroker.publishConsumerPacts('forms-api', pact_broker_config);
In its current form, this package assumes your pactbroker is secured with basic authentication and hence the need for user name and password as in the example code below. It should be made optional, Happy for receive a pull request regarding this or I shall fix it.
npm install jasmine-node -g
jasmine-node ./spec --autotest --color
This is NOT a PACT implementation / DSL.
For Ruby implementation For .NET implementation For JVM implementation For javscript implementation