nock 13.0.4 → 13.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -86,7 +86,7 @@ For instance, if a module performs HTTP requests to a CouchDB server or makes HT
86
86
  - [Usage](#usage-1)
87
87
  - [Options](#options-1)
88
88
  - [Example](#example)
89
- - [Modes](#modes)
89
+ - [Modes](#modes)
90
90
  - [Common issues](#common-issues)
91
91
  - [Axios](#axios)
92
92
  - [Memory issues with Jest](#memory-issues-with-jest)
@@ -376,7 +376,7 @@ const scope = nock('http://www.google.com')
376
376
  In Nock 11.x it was possible to invoke `.reply()` with a status code and a
377
377
  function that returns an array containing a status code and body. (The status
378
378
  code from the array would take precedence over the one passed directly to
379
- reply.) This is no longer allowed. In 12.x, either call `.reply()` with a
379
+ reply.) This is no longer allowed. In Nock 12 and later, either call `.reply()` with a
380
380
  status code and a function that returns the body, or call it with a single
381
381
  argument: a function that returns an array containing both the status code and
382
382
  body.
@@ -634,7 +634,6 @@ You are able to specify a non-standard port like this:
634
634
 
635
635
  ```js
636
636
  const scope = nock('http://my.server.com:8081')
637
- ...
638
637
  ```
639
638
 
640
639
  ### Repeat response n times
@@ -1064,7 +1063,7 @@ You can bypass Nock completely by setting the `NOCK_OFF` environment variable to
1064
1063
 
1065
1064
  This way you can have your tests hit the real servers just by switching on this environment variable.
1066
1065
 
1067
- ```js
1066
+ ```shell script
1068
1067
  $ NOCK_OFF=true node my_test.js
1069
1068
  ```
1070
1069
 
@@ -1304,10 +1303,10 @@ nock.removeInterceptor({
1304
1303
 
1305
1304
  ```js
1306
1305
  nock.removeInterceptor({
1307
- hostname : 'localhost',
1308
- path : '/login'
1309
- method: 'POST'
1310
- proto : 'https'
1306
+ hostname: 'localhost',
1307
+ path: '/login',
1308
+ method: 'POST',
1309
+ proto: 'https',
1311
1310
  })
1312
1311
  ```
1313
1312
 
@@ -1389,11 +1388,9 @@ nockBack('zomboFixture.json', nockDone => {
1389
1388
  If your tests are using promises then use `nockBack` like this:
1390
1389
 
1391
1390
  ```js
1392
- return nockBack('promisedFixture.json')
1393
- .then(({ nockDone, context }) => {
1394
- // do your tests returning a promise and chain it with
1395
- // `.then(nockDone)`
1396
- })
1391
+ return nockBack('promisedFixture.json').then(({ nockDone, context }) => {
1392
+ // do your tests returning a promise and chain it with
1393
+ // `.then(nockDone)`
1397
1394
  })
1398
1395
  ```
1399
1396
 
@@ -1411,7 +1408,7 @@ As an optional second parameter you can pass the following options
1411
1408
  ```js
1412
1409
  function prepareScope(scope) {
1413
1410
  scope.filteringRequestBody = (body, aRecordedBody) => {
1414
- if (typeof(body) !== 'string' || typeof(aRecordedBody) !== 'string') {
1411
+ if (typeof body !== 'string' || typeof aRecordedBody !== 'string') {
1415
1412
  return body
1416
1413
  }
1417
1414
 
@@ -1428,15 +1425,15 @@ function prepareScope(scope) {
1428
1425
  }
1429
1426
  }
1430
1427
 
1431
- nockBack('zomboFixture.json', { before: prepareScope }, nockDone => {
1432
- request.get('http://zombo.com', function(err, res, body) {
1428
+ nockBack('exampleFixture.json', { before: prepareScope }, nockDone => {
1429
+ request.get('http://example.com', function (err, res, body) {
1433
1430
  // do your tests
1434
1431
  nockDone()
1435
- }
1436
- }
1432
+ })
1433
+ })
1437
1434
  ```
1438
1435
 
1439
- #### Modes
1436
+ ### Modes
1440
1437
 
1441
1438
  To set the mode call `nockBack.setMode(mode)` or run the tests with the `NOCK_BACK_MODE` environment variable set before loading nock. If the mode needs to be changed programmatically, the following is valid: `nockBack.setMode(nockBack.currentMode)`
1442
1439
 
@@ -195,7 +195,9 @@ class InterceptedRequestRouter {
195
195
  req.once('finish', callback)
196
196
  }
197
197
 
198
- req.write(chunk, encoding)
198
+ if (chunk) {
199
+ req.write(chunk, encoding)
200
+ }
199
201
  req.finished = true
200
202
  this.maybeStartPlayback()
201
203
 
package/lib/scope.js CHANGED
@@ -331,7 +331,7 @@ function define(nockDefs) {
331
331
  let response
332
332
  if (!nockDef.response) {
333
333
  response = ''
334
- // TODO: Rename `responseIsBinary` to `reponseIsUtf8Representable`.
334
+ // TODO: Rename `responseIsBinary` to `responseIsUtf8Representable`.
335
335
  } else if (nockDef.responseIsBinary) {
336
336
  response = Buffer.from(nockDef.response, 'hex')
337
337
  } else {
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "testing",
8
8
  "isolation"
9
9
  ],
10
- "version": "13.0.4",
10
+ "version": "13.0.5",
11
11
  "author": "Pedro Teixeira <pedro.teixeira@gmail.com>",
12
12
  "repository": {
13
13
  "type": "git",
@@ -32,12 +32,12 @@
32
32
  "assert-rejects": "^1.0.0",
33
33
  "chai": "^4.1.2",
34
34
  "dirty-chai": "^2.0.1",
35
- "dtslint": "^3.0.0",
35
+ "dtslint": "^4.0.4",
36
36
  "eslint": "^7.3.1",
37
37
  "eslint-config-prettier": "^6.0.0",
38
38
  "eslint-config-standard": "^14.0.0",
39
39
  "eslint-plugin-import": "^2.16.0",
40
- "eslint-plugin-mocha": "^7.0.1",
40
+ "eslint-plugin-mocha": "^8.0.0",
41
41
  "eslint-plugin-node": "^11.0.0",
42
42
  "eslint-plugin-promise": "^4.1.1",
43
43
  "eslint-plugin-standard": "^4.0.0",
@@ -53,7 +53,7 @@
53
53
  "semantic-release": "^17.0.2",
54
54
  "sinon": "^9.0.0",
55
55
  "sinon-chai": "^3.3.0",
56
- "superagent": "^5.0.2",
56
+ "superagent": "^6.1.0",
57
57
  "tap": "14.6.1"
58
58
  },
59
59
  "scripts": {