Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nock

Package Overview
Dependencies
Maintainers
1
Versions
431
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nock - npm Package Compare versions

Comparing version 0.10.5 to 0.10.6

13

lib/intercept.js

@@ -45,9 +45,16 @@ var RequestOverrider = require('./request_overrider'),

options.proto = options.proto || 'http';
if (!options.host) {
options.host = options.hostname;
if (options.port)
options.host += ":" + options.port;
}
options.proto = options.proto || 'http';
if (
options.port && options.host.indexOf(':') < 0 &&
(options.port !== 80 || options.proto !== 'http') &&
(options.port !== 443 || options.proto !== 'https')
) {
options.host += ":" + options.port;
}
basePath = options.proto + '://' + options.host;

@@ -54,0 +61,0 @@

{ "name" : "nock"
, "description" : "HTTP Server mocking for Node.js"
, "tags" : ["Mock", "HTTP", "testing", "isolation"]
, "version" : "0.10.5"
, "version" : "0.10.6"
, "author" : "Pedro Teixeira <pedro.teixeira@gmail.com>"

@@ -6,0 +6,0 @@ , "contributors" :

@@ -90,4 +90,10 @@ # Nock [![Build Status](https://secure.travis-ci.org/flatiron/nock.png)](http://travis-ci.org/flatiron/nock)

Nock supports get, post, put and delete HTTP verbs.
Nock supports any HTTP verb, and it has convenience methods for the GET, POST, PUT and DELETE HTTP verbs.
You can intercept any HTTP verb using `.intercept(path, verb [, requestBody [, options]])`:
scope('http://my.domain.com')
.intercept('/path', 'HEAD')
.reply(304);
## Support for HTTP and HTTPS

@@ -100,2 +106,9 @@

## Non-standard ports
If you use HTTPS and port 80 or HTTPS and port 443, don't specify the port in the scope. Otherwise, you should specify the port like this:
var scope = nock('http://my.server.com:8081')
...
## Chaining

@@ -248,2 +261,13 @@

# PROTIP
If you don't want to match the request body you can use this trick (by @theycallmeswift):
var scope = nock('http://api.myservice.com')
.filteringRequestBody(function(path) {
return '*';
})
.post('/some_uri', '*')
.reply(200, 'OK');
# License

@@ -250,0 +274,0 @@

@@ -9,2 +9,3 @@ var nock = require('../.')

tap.test("get gets mocked", function(t) {

@@ -1233,1 +1234,32 @@ var dataCalled = false

});
tap.test('different ports work works', function(t) {
var scope = nock('http://abc.portyyyy.com:8081')
.log(console.log)
.get('/pathhh')
.reply(200, "Welcome, username");
http.request({
hostname: 'abc.portyyyy.com',
port: 8081,
path: '/pathhh'
}, function(res) {
scope.done();
t.end();
}).end();
});
tap.test('different ports work work with Mikeal request', function(t) {
var scope = nock('http://abc.portyyyy.com:8082')
.log(console.log)
.get('/pathhh')
.reply(200, "Welcome to Mikeal Request!");
mikealRequest.get('http://abc.portyyyy.com:8082/pathhh', function(err, res, body) {
console.log(err);
t.ok(! err, 'no error');
t.equal(body, 'Welcome to Mikeal Request!');
t.ok(scope.isDone());
t.end();
});
});
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