Socket
Socket
Sign inDemoInstall

@pact-foundation/pact-node

Package Overview
Dependencies
Maintainers
4
Versions
187
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pact-foundation/pact-node - npm Package Compare versions

Comparing version 4.2.1 to 4.3.0

3

package.json
{
"name": "@pact-foundation/pact-node",
"version": "4.2.1",
"version": "4.3.0",
"description": "A wrapper for the Ruby version of Pact to work within Node",

@@ -47,2 +47,3 @@ "main": "./src/pact.js",

"commander": "^2.9.0",
"mkdirp": "^0.5.1",
"q": "^1.4.1",

@@ -49,0 +50,0 @@ "request": "^2.69.0",

@@ -59,2 +59,21 @@ /* global describe:true, before:true, after:true, it:true, global:true, process:true */

describe("Create serverFactory", function () {
var fs = require('fs'),
path = require('path'),
dirPath;
beforeEach(function () {
dirPath = path.resolve(__dirname, '../.tmp/' + Math.floor(Math.random() * 1000));
});
afterEach(function (done) {
try {
if (fs.statSync(dirPath).isDirectory()) {
fs.rmdirSync(dirPath);
}
} catch (e) {
}
done();
});
context("when no options are set", function () {

@@ -73,11 +92,2 @@ it("should use defaults and return serverFactory", function () {

context("when user specifies valid options", function () {
var fs = require('fs'),
path = require('path'),
dirPath = path.resolve(__dirname, '../.tmp' + Math.floor(Math.random() * 1000));
beforeEach(function (done) {
fs.mkdir(dirPath, done);
});
afterEach(function (done) {
fs.rmdir(dirPath, done);
});

@@ -155,6 +165,5 @@ it("should return serverFactory using specified options", function () {

context("when user specifies invalid pact directory", function () {
it("should return an error on invalid path", function () {
expect(function () {
pact.createServer({dir: 'M:/nms'});
}).to.throw(Error);
it("should create the directory for us", function () {
pact.createServer({dir: dirPath});
expect(fs.statSync(dirPath).isDirectory()).to.be.true;
});

@@ -181,5 +190,4 @@ });

it("should return an error on invalid path", function () {
expect(function () {
pact.createServer({log: 'abc/123'});
}).to.throw(Error);
pact.createServer({log: path.resolve(dirPath, 'log.txt')});
expect(fs.statSync(dirPath).isDirectory()).to.be.true;
});

@@ -267,25 +275,24 @@ });

// TODO: uncomment once signature is back
/*describe("Verify Pacts", function () {
context("With provider states", function () {
it("should start the pact-provider-verifier service and verify pacts", function () {
var opts = {
providerBaseUrl: "http://localhost",
pactUrls: [ path.dirname(process.mainModule.filename) ]
};
return expect(pact.verifyPacts(opts)).to.eventually.be.resolved;
});
});
});
describe("Verify Pacts", function () {
context("With provider states", function () {
it("should start the pact-provider-verifier service and verify pacts", function () {
var opts = {
providerBaseUrl: "http://localhost",
pactUrls: [path.dirname(process.mainModule.filename)]
};
return expect(pact.verifyPacts(opts)).to.eventually.be.resolved;
});
});
});
describe("Publish Pacts", function () {
it("should start running the Pact publishig process", function () {
var opts = {
pactBroker: "http://localhost",
pactUrls: [ path.dirname(process.mainModule.filename) ],
consumerVersion: "1.0.0"
};
return expect(pact.publishPacts(opts)).to.eventually.be.resolved;
});
});*/
describe("Publish Pacts", function () {
it("should start running the Pact publishig process", function () {
var opts = {
pactBroker: "http://localhost",
pactUrls: [path.dirname(process.mainModule.filename)],
consumerVersion: "1.0.0"
};
return expect(pact.publishPacts(opts)).to.eventually.be.resolved;
});
});
});

@@ -13,3 +13,4 @@ 'use strict';

util = require('util'),
pactPath = require('@pact-foundation/pact-mock-service');
pactPath = require('@pact-foundation/pact-mock-service'),
mkdirp = require('mkdirp');
var isWindows = process.platform === 'win32';

@@ -264,4 +265,8 @@

// dir check
if (!fs.statSync(path.normalize(options.dir)).isDirectory()) {
// If directory doesn't exist, create it
if (options.dir) {
try {
fs.statSync(path.normalize(options.dir)).isDirectory();
} catch (e) {
mkdirp.sync(path.normalize(options.dir));
}
}

@@ -271,3 +276,9 @@

if (options.log) {
checkTypes.assert(fs.statSync(path.dirname(path.normalize(options.log))).isDirectory(), "Error on log, not a valid path");
var fileObj = path.parse(path.normalize(options.log));
try {
fs.statSync(fileObj.dir).isDirectory();
} catch (e) {
// If log path doesn't exist, create it
mkdirp.sync(fileObj.dir);
}
}

@@ -274,0 +285,0 @@

@@ -38,10 +38,16 @@ /* global describe:true, before:true, after:true, it:true, global:true, process:true */

var dirPath = path.resolve(__dirname, '../.tmp' + Math.floor(Math.random() * 1000));
var dirPath;
beforeEach(function (done) {
fs.mkdir(dirPath, done);
beforeEach(function () {
dirPath = path.resolve(__dirname, '../.tmp/' + Math.floor(Math.random() * 1000));
});
afterEach(function (done) {
fs.rmdir(dirPath, done);
try {
if (fs.statSync(dirPath).isDirectory()) {
fs.rmdirSync(dirPath);
}
} catch (e) {
}
done();
});

@@ -106,5 +112,6 @@

it("should start correctly with log", function (done) {
server = serverFactory({log: 'log.txt'});
var logPath = path.resolve(dirPath, 'log.txt');
server = serverFactory({log: logPath});
server.start().then(function () {
expect(server.options.log).to.equal('log.txt');
expect(server.options.log).to.equal(logPath);
done();

@@ -111,0 +118,0 @@ });

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc