New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nock

Package Overview
Dependencies
Maintainers
1
Versions
438
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.21.0 to 0.22.0

15

lib/scope.js

@@ -185,3 +185,15 @@ var path = require('path')

}
function once() {
return this.times(1);
}
function twice() {
return this.times(2);
}
function thrice() {
return this.times(3);
}
var interceptor = {

@@ -199,2 +211,5 @@ _key: key

, times: times
, once: once
, twice: twice
, thrice: thrice
};

@@ -201,0 +216,0 @@

2

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

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

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

```js
nock('http://zombo.com').get('/').times(2).reply(200, 'Ok');
nock('http://zombo.com').get('/').times(4).reply(200, 'Ok');
http.get('http://zombo.com/'); // respond body "Ok"
http.get('http://zombo.com/'); // respond body "Ok"
http.get('http://zombo.com/'); // respond body "Ok"
http.get('http://zombo.com/'); // respond body "Ok"
http.get('http://zombo.com/'); // respond with zombo.com result
```
Sugar sintaxe
```js
nock('http://zombo.com').get('/').once().reply(200, 'Ok');
nock('http://zombo.com').get('/').twice().reply(200, 'Ok');
nock('http://zombo.com').get('/').thrice().reply(200, 'Ok');
```
## Chaining

@@ -161,0 +171,0 @@

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

test('repeating response 2 times', function(t) {
test('repeating once', function(t) {
nock.disableNetConnect();

@@ -1865,12 +1865,28 @@

.get('/')
.times(2)
.once()
.reply(200, "Hello World!");
http.get('http://zombo.com', function(res) {
t.equal(200, res.statusCode, 'first request');
});
nock.cleanAll()
t.end();
http.get('http://zombo.com', function(res) {
t.equal(200, res.statusCode, 'second request');
});
nock.enableNetConnect();
});
test('repeating twice', function(t) {
nock.disableNetConnect();
var _mock = nock('http://zombo.com')
.get('/')
.twice()
.reply(200, "Hello World!");
for (var i=0; i < 2; i++) {
http.get('http://zombo.com', function(res) {
t.equal(200, res.statusCode, 'first request');
});
};

@@ -1882,1 +1898,41 @@ nock.cleanAll()

});
test('repeating thrice', function(t) {
nock.disableNetConnect();
var _mock = nock('http://zombo.com')
.get('/')
.thrice()
.reply(200, "Hello World!");
for (var i=0; i < 3; i++) {
http.get('http://zombo.com', function(res) {
t.equal(200, res.statusCode, 'first request');
});
};
nock.cleanAll()
t.end();
nock.enableNetConnect();
});
test('repeating response 4 times', function(t) {
nock.disableNetConnect();
var _mock = nock('http://zombo.com')
.get('/')
.times(4)
.reply(200, "Hello World!");
for (var i=0; i < 4; i++) {
http.get('http://zombo.com', function(res) {
t.equal(200, res.statusCode, 'first request');
});
};
nock.cleanAll()
t.end();
nock.enableNetConnect();
});
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