nock
Advanced tools
Comparing version 13.0.4 to 13.0.5
@@ -198,3 +198,5 @@ 'use strict' | ||
req.write(chunk, encoding) | ||
if (chunk) { | ||
req.write(chunk, encoding) | ||
} | ||
req.finished = true | ||
@@ -201,0 +203,0 @@ this.maybeStartPlayback() |
@@ -334,3 +334,3 @@ 'use strict' | ||
response = '' | ||
// TODO: Rename `responseIsBinary` to `reponseIsUtf8Representable`. | ||
// TODO: Rename `responseIsBinary` to `responseIsUtf8Representable`. | ||
} else if (nockDef.responseIsBinary) { | ||
@@ -337,0 +337,0 @@ response = Buffer.from(nockDef.response, 'hex') |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "13.0.4", | ||
"version": "13.0.5", | ||
"author": "Pedro Teixeira <pedro.teixeira@gmail.com>", | ||
@@ -36,3 +36,3 @@ "repository": { | ||
"dirty-chai": "^2.0.1", | ||
"dtslint": "^3.0.0", | ||
"dtslint": "^4.0.4", | ||
"eslint": "^7.3.1", | ||
@@ -42,3 +42,3 @@ "eslint-config-prettier": "^6.0.0", | ||
"eslint-plugin-import": "^2.16.0", | ||
"eslint-plugin-mocha": "^7.0.1", | ||
"eslint-plugin-mocha": "^8.0.0", | ||
"eslint-plugin-node": "^11.0.0", | ||
@@ -59,3 +59,3 @@ "eslint-plugin-promise": "^4.1.1", | ||
"sinon-chai": "^3.3.0", | ||
"superagent": "^5.0.2", | ||
"superagent": "^6.1.0", | ||
"tap": "14.6.1" | ||
@@ -62,0 +62,0 @@ }, |
@@ -89,3 +89,3 @@ # Nock | ||
- [Example](#example) | ||
- [Modes](#modes) | ||
- [Modes](#modes) | ||
- [Common issues](#common-issues) | ||
@@ -380,3 +380,3 @@ - [Axios](#axios) | ||
code from the array would take precedence over the one passed directly to | ||
reply.) This is no longer allowed. In 12.x, either call `.reply()` with a | ||
reply.) This is no longer allowed. In Nock 12 and later, either call `.reply()` with a | ||
status code and a function that returns the body, or call it with a single | ||
@@ -639,3 +639,2 @@ argument: a function that returns an array containing both the status code and | ||
const scope = nock('http://my.server.com:8081') | ||
... | ||
``` | ||
@@ -1070,3 +1069,3 @@ | ||
```js | ||
```shell script | ||
$ NOCK_OFF=true node my_test.js | ||
@@ -1311,6 +1310,6 @@ ``` | ||
nock.removeInterceptor({ | ||
hostname : 'localhost', | ||
path : '/login' | ||
method: 'POST' | ||
proto : 'https' | ||
hostname: 'localhost', | ||
path: '/login', | ||
method: 'POST', | ||
proto: 'https', | ||
}) | ||
@@ -1397,7 +1396,5 @@ ``` | ||
```js | ||
return nockBack('promisedFixture.json') | ||
.then(({ nockDone, context }) => { | ||
// do your tests returning a promise and chain it with | ||
// `.then(nockDone)` | ||
}) | ||
return nockBack('promisedFixture.json').then(({ nockDone, context }) => { | ||
// do your tests returning a promise and chain it with | ||
// `.then(nockDone)` | ||
}) | ||
@@ -1420,3 +1417,3 @@ ``` | ||
scope.filteringRequestBody = (body, aRecordedBody) => { | ||
if (typeof(body) !== 'string' || typeof(aRecordedBody) !== 'string') { | ||
if (typeof body !== 'string' || typeof aRecordedBody !== 'string') { | ||
return body | ||
@@ -1438,11 +1435,11 @@ } | ||
nockBack('zomboFixture.json', { before: prepareScope }, nockDone => { | ||
request.get('http://zombo.com', function(err, res, body) { | ||
nockBack('exampleFixture.json', { before: prepareScope }, nockDone => { | ||
request.get('http://example.com', function (err, res, body) { | ||
// do your tests | ||
nockDone() | ||
} | ||
} | ||
}) | ||
}) | ||
``` | ||
#### Modes | ||
### Modes | ||
@@ -1449,0 +1446,0 @@ 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)` |
173767
3397
1589