
Grunt Pact
UPGRADE NOTICE
If you are using grunt-pact as a dependency in your project, please update it to @pact-foundation/grunt-pact.
A grunt task to run pact on node.
Getting Started
This plugin requires Grunt >=0.4.0
(works with 1.X)
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-pact --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-pact');
The "pact" task
Overview
In your project's Gruntfile, add a section named pact
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
pact: {
options: {
force: <Boolean>,
logLevel: <String>,
port: <Number>,
host: <String>,
log: <String>,
ssl: <Boolean>,
cors: <Boolean>,
dir: <String>,
spec: <Number>,
consumer: <String>,
provider: <String>
},
your_target: {
src:['mocks/**/*.pact.js']
},
},
});
Options
All pact-mock-service options are available to grunt-pact.
options.force
Type: Boolean
Default value: false
While running through pact files, this will prevent grunt from stopping if an error occurs.
options.logLevel
Type: String
Default value: 'info'
Sets the log level for Pact when running. Can be set to 'trace', 'debug', 'info', 'warn', 'error' or 'fatal'.
options.port
Type: Number
Default value: 1234
Port number that the server runs on.
options.host
Type: String
Default value: 'localhost'
Host on which to bind the server on. You probably don't need to use this.
options.log
Type: String
Default value: ''
File to log output on relative to current working directory.
options.ssl
Type: Boolean
Default value: false
Create a self-signed SSL cert to run the server over HTTPS.
options.cors
Type: Boolean
Default value: false
Allow CORS OPTION requests to be accepted.
options.dir
Type: String
Default value: ''
Directory to write the pact contracts relative to the current working directory.
options.spec
Type: Number
Default value: 1
The pact specification version to use when writing pact contracts.
options.consumer
Type: String
Default value: ''
The name of the consumer to be written to the pact contracts. This can be set via the API.
options.provider
Type: String
Default value: '.'
The name of the provider to be written to the pact contracts. This can be set via the API.