node-consumer-pact-interceptor
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -5,17 +5,10 @@ 'use strict'; | ||
var pact = require('./post-pact.json'); | ||
var interceptor = intercept(pact); | ||
var client = require('./sample-consumer-client'); | ||
var expect = require('chai').expect; | ||
describe('Pact consumer test', function(){ | ||
describe('When the request matches the specification', function(){ | ||
before(function(){ | ||
var response; | ||
var response; | ||
before(function(done){ | ||
interceptor.start('http://somedomain/some-resource/1234', function(err, pactData){ | ||
if(err) | ||
throw err; | ||
}); | ||
var setState = function(err, interaction, cb){ | ||
client(1234, { foo: "baz"}, function(err, res){ | ||
@@ -30,6 +23,9 @@ if(err){ | ||
}); | ||
}); | ||
}; | ||
after(function(){ | ||
interceptor.teardown(); | ||
intercept(pact, /.*/, setState, function(err, testResults){ | ||
if(err){ | ||
console.error(err); //Failure in setting up tests | ||
} | ||
}); | ||
}); | ||
@@ -36,0 +32,0 @@ |
{ | ||
"name": "node-consumer-pact-interceptor", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "A means to intercept outgoing requests for the purpose of validating consumer pacts", | ||
@@ -25,3 +25,3 @@ "main": "index.js", | ||
"lodash": "^3.10.1", | ||
"node-consumer-pact-validation": "^1.0.2", | ||
"node-consumer-pact-validation": "^1.0.3", | ||
"mitm": "^1.2.0", | ||
@@ -28,0 +28,0 @@ "request": "^2.67.0", |
@@ -18,5 +18,5 @@ ### Node Consumer Pact interceptor | ||
1. Create pact JSON spec | ||
2. Feed this to the interceptor (As below examples) | ||
3. Send requests as expected to the provider, they will be intercepted as outgoing HTTP requests | ||
4. Throw any failures received by the interceptor, else verify the response is as expected | ||
2. Create a setState function to pass to the interceptor, the setState function typically send a request to the api under test. | ||
3. Request will be intercepted as outgoing HTTP requests | ||
4. Verify the response(s) returned from the interceptor. | ||
5. Publish pact to broker | ||
@@ -31,3 +31,3 @@ | ||
We found that it was difficult to induct new developers into using this system and the | ||
incidental complexity barrier (often compounted by CI servers and docker-containers) | ||
incidental complexity barrier (often compounded by CI servers and docker-containers) | ||
was such that this became a real pain-point. | ||
@@ -50,6 +50,5 @@ | ||
to fully meet the requirements of nested type-matching. | ||
- This is **Based around a single interaction per pact-file**. This was a first-cut | ||
design-decsion and will be revisited if it appears necessary. | ||
- Outgoing HTTP or socket requests which are not part of the pact test are going to be blocked. | ||
This is unfortunate and less than ideal. I have not yet found a way to use MITM's API to allow | ||
HTTP requests on a per-url basis. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16147
15
416
52