api documentation for nock (v9.0.13)

HTTP Server mocking for Node.js

table of contents

  1. module nock
    1. function nock (basePath, options)
    2. function nock.activate ()
    3. function nock.activeMocks ()
    4. function nock.back (fixtureName, options, nockedFn)
    5. function nock.cleanAll ()
    6. function nock.define (nockDefs)
    7. function nock.delayed_body (ms, body)
    8. function nock.disableNetConnect ()
    9. function nock.enableNetConnect (matcher)
    10. function nock.intercept (key, interceptor, scope, scopeOptions, host)
    11. function nock.interceptor (scope, uri, method, requestBody, interceptorOptions)
    12. function nock.isActive ()
    13. function nock.isDone ()
    14. function nock.load (path)
    15. function nock.loadDefs (path)
    16. function nock.pendingMocks ()
    17. function nock.removeInterceptor (options)
    18. function nock.restore ()
    19. function nock.scope (basePath, options)
    20. function nock.socket (options)
    21. object nock.common
    22. object nock.delayed_body.prototype
    23. object nock.emitter
    24. object nock.interceptor.prototype
    25. object nock.recorder
    26. object nock.socket.prototype
  2. module nock.back
    1. function nock.back (fixtureName, options, nockedFn)
    2. function nock.back.setMode (mode)
    3. object nock.back.fixtures
    4. string nock.back.currentMode
  3. module nock.common
    1. function nock.common.contentEncoding (headers, encoder)
    2. function nock.common.deleteHeadersField (headers, fieldNameToDelete)
    3. function nock.common.formatQueryValue (key, value, options)
    4. function nock.common.headersArrayToObject (rawHeaders)
    5. function nock.common.headersFieldNamesToLowerCase (headers)
    6. function nock.common.headersFieldsArrayToLowerCase (headers)
    7. function nock.common.isBinaryBuffer (buffer)
    8. function nock.common.isContentEncoded (headers)
    9. function nock.common.isJSONContent (headers)
    10. function nock.common.isStream (obj)
    11. function nock.common.matchStringOrRegexp (target, pattern)
    12. function nock.common.mergeChunks (chunks)
    13. function nock.common.normalizeRequestOptions (options)
    14. function nock.common.overrideRequests (newRequest)
    15. function nock.common.percentDecode (str)
    16. function nock.common.percentEncode (str)
    17. function nock.common.restoreOverriddenRequests ()
    18. function nock.common.stringifyRequest (options, body)
  4. module nock.delayed_body
    1. function nock.delayed_body (ms, body)
    2. function nock.delayed_body.super_ (options)
  5. module nock.delayed_body.prototype
    1. function nock.delayed_body.prototype._transform (chunk, encoding, cb)
  6. module nock.intercept
    1. function nock.intercept (key, interceptor, scope, scopeOptions, host)
    2. function nock.intercept.activate ()
    3. function nock.intercept.activeMocks ()
    4. function nock.intercept.disableNetConnect ()
    5. function nock.intercept.enableNetConnect (matcher)
    6. function nock.intercept.isActive ()
    7. function nock.intercept.isDone ()
    8. function nock.intercept.isOn ()
    9. function nock.intercept.overrideClientRequest ()
    10. function nock.intercept.pendingMocks ()
    11. function nock.intercept.removeAll ()
    12. function nock.intercept.removeInterceptor (options)
    13. function nock.intercept.restoreOverriddenClientRequest ()
  7. module nock.interceptor
    1. function nock.interceptor (scope, uri, method, requestBody, interceptorOptions)
  8. module nock.interceptor.prototype
    1. function nock.interceptor.prototype.basicAuth (options)
    2. function nock.interceptor.prototype.delay (opts)
    3. function nock.interceptor.prototype.delayBody (ms)
    4. function nock.interceptor.prototype.delayConnection (ms)
    5. function nock.interceptor.prototype.discard ()
    6. function nock.interceptor.prototype.filteringPath ()
    7. function nock.interceptor.prototype.getTotalDelay ()
    8. function nock.interceptor.prototype.match (options, body, hostNameOnly)
    9. function nock.interceptor.prototype.matchHeader (name, value)
    10. function nock.interceptor.prototype.matchIndependentOfBody (options)
    11. function nock.interceptor.prototype.once ()
    12. function nock.interceptor.prototype.optionally ()
    13. function nock.interceptor.prototype.query (queries)
    14. function nock.interceptor.prototype.reply (statusCode, body, rawHeaders)
    15. function nock.interceptor.prototype.replyWithError (errorMessage)
    16. function nock.interceptor.prototype.replyWithFile (statusCode, filePath, headers)
    17. function nock.interceptor.prototype.reqheaderMatches (options, key)
    18. function nock.interceptor.prototype.socketDelay (ms)
    19. function nock.interceptor.prototype.thrice ()
    20. function nock.interceptor.prototype.times (newCounter)
    21. function nock.interceptor.prototype.twice ()
  9. module nock.recorder
    1. function nock.recorder.clear ()
    2. function nock.recorder.play ()
    3. function nock.recorder.rec (rec_options)
  10. module nock.scope
    1. function nock.scope (basePath, options)
    2. function nock.scope.activate ()
    3. function nock.scope.activeMocks ()
    4. function nock.scope.back (fixtureName, options, nockedFn)
    5. function nock.scope.cleanAll ()
    6. function nock.scope.define (nockDefs)
    7. function nock.scope.disableNetConnect ()
    8. function nock.scope.enableNetConnect (matcher)
    9. function nock.scope.isActive ()
    10. function nock.scope.isDone ()
    11. function nock.scope.load (path)
    12. function nock.scope.loadDefs (path)
    13. function nock.scope.pendingMocks ()
    14. function nock.scope.removeInterceptor (options)
    15. function nock.scope.restore ()
    16. object nock.scope.emitter
    17. object nock.scope.recorder
  11. module nock.socket
    1. function nock.socket (options)
    2. function nock.socket.super_ ()
  12. module nock.socket.prototype
    1. function nock.socket.prototype.applyDelay (delayMs)
    2. function nock.socket.prototype.destroy ()
    3. function nock.socket.prototype.getPeerCertificate ()
    4. function nock.socket.prototype.setTimeout (timeoutMs, fn)

module nock

function nock (basePath, options)

function nock.activate ()

function nock.activeMocks ()

function nock.back (fixtureName, options, nockedFn)

function nock.cleanAll ()

function nock.define (nockDefs)

function nock.delayed_body (ms, body)

function nock.disableNetConnect ()

function nock.enableNetConnect (matcher)

function nock.intercept (key, interceptor, scope, scopeOptions, host)

function nock.interceptor (scope, uri, method, requestBody, interceptorOptions)

function nock.isActive ()

function nock.isDone ()

function nock.load (path)

function nock.loadDefs (path)

function nock.pendingMocks ()

function nock.removeInterceptor (options)

function nock.restore ()

function nock.scope (basePath, options)

function nock.socket (options)

module nock.back

function nock.back (fixtureName, options, nockedFn)

function nock.back.setMode (mode)

module nock.common

function nock.common.contentEncoding (headers, encoder)

function nock.common.deleteHeadersField (headers, fieldNameToDelete)

function nock.common.formatQueryValue (key, value, options)

function nock.common.headersArrayToObject (rawHeaders)

function nock.common.headersFieldNamesToLowerCase (headers)

function nock.common.headersFieldsArrayToLowerCase (headers)

function nock.common.isBinaryBuffer (buffer)

function nock.common.isContentEncoded (headers)

function nock.common.isJSONContent (headers)

function nock.common.isStream (obj)

function nock.common.matchStringOrRegexp (target, pattern)

function nock.common.mergeChunks (chunks)

function nock.common.normalizeRequestOptions (options)

function nock.common.overrideRequests (newRequest)

function nock.common.percentDecode (str)

function nock.common.percentEncode (str)

function nock.common.restoreOverriddenRequests ()

function nock.common.stringifyRequest (options, body)

module nock.delayed_body

function nock.delayed_body (ms, body)

function nock.delayed_body.super_ (options)

module nock.delayed_body.prototype

function nock.delayed_body.prototype._transform (chunk, encoding, cb)

module nock.intercept

function nock.intercept (key, interceptor, scope, scopeOptions, host)

function nock.intercept.activate ()

function nock.intercept.activeMocks ()

function nock.intercept.disableNetConnect ()

function nock.intercept.enableNetConnect (matcher)

function nock.intercept.isActive ()

function nock.intercept.isDone ()

function nock.intercept.isOn ()

function nock.intercept.overrideClientRequest ()

function nock.intercept.pendingMocks ()

function nock.intercept.removeAll ()

function nock.intercept.removeInterceptor (options)

function nock.intercept.restoreOverriddenClientRequest ()

module nock.interceptor

function nock.interceptor (scope, uri, method, requestBody, interceptorOptions)

module nock.interceptor.prototype

function nock.interceptor.prototype.basicAuth (options)

function nock.interceptor.prototype.delay (opts)

function nock.interceptor.prototype.delayBody (ms)

function nock.interceptor.prototype.delayConnection (ms)

function nock.interceptor.prototype.discard ()

function nock.interceptor.prototype.filteringPath ()

function nock.interceptor.prototype.getTotalDelay ()

function nock.interceptor.prototype.match (options, body, hostNameOnly)

function nock.interceptor.prototype.matchHeader (name, value)

function nock.interceptor.prototype.matchIndependentOfBody (options)

function nock.interceptor.prototype.once ()

function nock.interceptor.prototype.optionally ()

function nock.interceptor.prototype.query (queries)

function nock.interceptor.prototype.reply (statusCode, body, rawHeaders)

function nock.interceptor.prototype.replyWithError (errorMessage)

function nock.interceptor.prototype.replyWithFile (statusCode, filePath, headers)

function nock.interceptor.prototype.reqheaderMatches (options, key)

function nock.interceptor.prototype.socketDelay (ms)

function nock.interceptor.prototype.thrice ()

function nock.interceptor.prototype.times (newCounter)

function nock.interceptor.prototype.twice ()

module nock.recorder

function nock.recorder.clear ()

function nock.recorder.play ()

function nock.recorder.rec (rec_options)

module nock.scope

function nock.scope (basePath, options)

function nock.scope.activate ()

function nock.scope.activeMocks ()

function nock.scope.back (fixtureName, options, nockedFn)

function nock.scope.cleanAll ()

function nock.scope.define (nockDefs)

function nock.scope.disableNetConnect ()

function nock.scope.enableNetConnect (matcher)

function nock.scope.isActive ()

function nock.scope.isDone ()

function nock.scope.load (path)

function nock.scope.loadDefs (path)

function nock.scope.pendingMocks ()

function nock.scope.removeInterceptor (options)

function nock.scope.restore ()

module nock.socket

function nock.socket (options)

function nock.socket.super_ ()

module nock.socket.prototype

function nock.socket.prototype.applyDelay (delayMs)

function nock.socket.prototype.destroy ()

function nock.socket.prototype.getPeerCertificate ()

function nock.socket.prototype.setTimeout (timeoutMs, fn)

[ this document was created with utility2 ]