Socket
Socket
Sign inDemoInstall

nock

Package Overview
Dependencies
Maintainers
4
Versions
430
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 13.1.4 to 13.2.0

56

lib/back.js

@@ -178,2 +178,43 @@ 'use strict'

const update = {
setup: function () {
recorder.restore()
recorder.clear()
cleanAll()
activate()
disableNetConnect()
},
start: function (fixture, options) {
if (!fs) {
throw new Error('no fs')
}
const context = removeFixture(fixture)
recorder.record({
dont_print: true,
output_objects: true,
...options.recorder,
})
context.isRecording = true
return context
},
finish: function (fixture, options, context) {
let outputs = recorder.outputs()
if (typeof options.afterRecord === 'function') {
outputs = options.afterRecord(outputs)
}
outputs =
typeof outputs === 'string' ? outputs : JSON.stringify(outputs, null, 4)
debug('recorder outputs:', outputs)
fs.mkdirSync(path.dirname(fixture), { recursive: true })
fs.writeFileSync(fixture, outputs)
},
}
const lockdown = {

@@ -219,2 +260,15 @@ setup: function () {

function removeFixture(fixture, options) {
const context = {
scopes: [],
assertScopesFinished: function () {},
}
if (fixture && fixtureExists(fixture)) {
fs.rmSync ? fs.rmSync(fixture) : fs.unlinkSync(fixture)
}
context.isLoaded = false
return context
}
function applyHook(scopes, fn) {

@@ -263,2 +317,4 @@ if (!fn) {

update, // allow http calls, record all nocks, don't use recorded nocks
lockdown, // use recorded nocks, disables all http calls even when not nocked, doesnt record

@@ -265,0 +321,0 @@ }

12

lib/common.js

@@ -654,7 +654,9 @@ 'use strict'

const wrapTimer = (timer, ids) => (...args) => {
const id = timer(...args)
ids.push(id)
return id
}
const wrapTimer =
(timer, ids) =>
(...args) => {
const id = timer(...args)
ids.push(id)
return id
}

@@ -661,0 +663,0 @@ const setTimeout = wrapTimer(timers.setTimeout, timeouts)

@@ -282,5 +282,4 @@ 'use strict'

// representation.
const requestBodyIsUtf8Representable = common.isUtf8Representable(
requestBodyBuffer
)
const requestBodyIsUtf8Representable =
common.isUtf8Representable(requestBodyBuffer)
const requestBodyString = requestBodyBuffer.toString(

@@ -287,0 +286,0 @@ requestBodyIsUtf8Representable ? 'utf8' : 'hex'

@@ -10,3 +10,3 @@ {

],
"version": "13.1.4",
"version": "13.2.0",
"author": "Pedro Teixeira <pedro.teixeira@gmail.com>",

@@ -32,3 +32,3 @@ "repository": {

"devDependencies": {
"@sinonjs/fake-timers": "^7.0.2",
"@sinonjs/fake-timers": "^8.1.0",
"assert-rejects": "^1.0.0",

@@ -42,3 +42,3 @@ "chai": "^4.1.2",

"eslint-plugin-import": "^2.16.0",
"eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-mocha": "^9.0.0",
"eslint-plugin-node": "^11.0.0",

@@ -52,8 +52,8 @@ "eslint-plugin-promise": "^4.1.1",

"nyc": "^15.0.0",
"prettier": "2.2.1",
"prettier": "2.4.1",
"proxyquire": "^2.1.0",
"rimraf": "^3.0.0",
"semantic-release": "^17.0.2",
"sinon": "^10.0.0",
"sinon-chai": "^3.3.0",
"sinon": "^12.0.1",
"sinon-chai": "^3.7.0",
"typescript": "^4.2.2"

@@ -68,3 +68,3 @@ },

"lint:ts": "dtslint types",
"test": "nyc mocha tests",
"test": "nyc --reporter=lcov --reporter=text mocha tests",
"test:coverage": "open coverage/lcov-report/index.html"

@@ -71,0 +71,0 @@ },

@@ -1326,2 +1326,14 @@ # Nock

**Note** `.reply(...)` method returns Scope, not Interceptor, and so it is not a valid argument for `nock.removeInterceptor`. So if your method chain ends with `.reply` to be used with `nock.removeInterceptor` the chain need to be break in between:
```js
// this will NOT work
const interceptor = nock('http://example.org').get('somePath').reply(200, 'OK')
nock.removeInterceptor(interceptor)
// this is how it should be
const interceptor = nock('http://example.org').get('somePath')
interceptor.reply(200, 'OK')
nock.removeInterceptor(interceptor)
```
## Events

@@ -1463,2 +1475,4 @@

- update: remove recorded nocks, record nocks
- lockdown: use recorded nocks, disables all http calls even when not nocked, doesn't record

@@ -1596,2 +1610,3 @@

<td align="center"><a href="http://www.laurencemyers.com.au"><img src="https://avatars.githubusercontent.com/u/6336048?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Laurence Dougal Myers</b></sub></a><br /><a href="https://github.com/nock/nock/commits?author=laurence-myers" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Beretta1979"><img src="https://avatars.githubusercontent.com/u/10073962?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sébastien Van Bruaene</b></sub></a><br /><a href="https://github.com/nock/nock/commits?author=Beretta1979" title="Code">💻</a> <a href="https://github.com/nock/nock/commits?author=Beretta1979" title="Tests">⚠️</a></td>
</tr>

@@ -1598,0 +1613,0 @@ </table>

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