@pact-foundation/grunt-pact
v4.3.0
Published
A grunt task to run pact easily
Downloads
27
Readme
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: {
// Grunt Pact Specific Options
force: <Boolean>, // Continue if one of the pact files errors, defaults to 'false'
logLevel: <String>, // Specify log level, either 'trace', 'debug', 'info', 'warn', 'error' or 'fatal', defaults to 'info'
// Pact Specific Options Go Here
port: <Number>, // Port number that the server runs on, defaults to 1234
host: <String>, // Host on which to bind the server on, defaults to 'localhost'
log: <String>, // File to log output on relative to current working directory, defaults to none
ssl: <Boolean>, // Create a self-signed SSL cert to run the server over HTTPS, defaults to 'false'
cors: <Boolean>, // Allow CORS OPTION requests to be accepted, defaults to 'false'
dir: <String>, // Directory to write the pact contracts relative to the current working directory, defaults to none
spec: <Number>, // The pact specification version to use when writing pact contracts, defaults to '1'
consumer: <String>, // The name of the consumer to be written to the pact contracts, defaults to none
provider: <String> // The name of the provider to be written to the pact contracts, defaults to none
},
your_target: {
// Specify Pact configuration files here
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.