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

nock

Package Overview
Dependencies
Maintainers
1
Versions
436
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.13.7 to 0.14.0

12

lib/scope.js

@@ -23,3 +23,4 @@ var path = require('path')

urlParts = url.parse(basePath),
port = urlParts.port || ((urlParts.protocol === 'http:') ? 80 : 443);
port = urlParts.port || ((urlParts.protocol === 'http:') ? 80 : 443),
persist = false;

@@ -37,2 +38,3 @@ basePath = urlParts.protocol + '//' + urlParts.hostname + ':' + port;

function remove(key, interceptor) {
if (persist) return;
var arr = interceptors[key];

@@ -168,3 +170,3 @@ if (arr) {

function discard() {
remove(this._key, this);
if (! persist) remove(this._key, this);
}

@@ -302,2 +304,7 @@

}
function _persist() {
persist = true;
return this;
}

@@ -318,2 +325,3 @@ scope = {

, log: log
, persist: _persist
};

@@ -320,0 +328,0 @@

2

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

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

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

## .persist()
You can make all the interceptors for a scope persist by calling `.persist()` on it:
```js
var scope = nock('http://persisssists.con')
.persist()
.get('/')
.reply(200, "Persisting all the way");
```
## Specifying request body

@@ -41,0 +52,0 @@

@@ -1573,2 +1573,14 @@ var nock = require('../.')

req.end();
});
tap.test('persists interceptors', function(t) {
var scope = nock('http://persisssists.con')
.persist()
.get('/')
.reply(200, "Persisting all the way");
http.get('http://persisssists.con/', function(res) {
t.ok(! scope.isDone());
t.end();
}).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