Trait/Object

io.scalajs.npm.nock

Nock

Related Docs: object Nock | package nock

Permalink

trait Nock extends Object

Nock is an HTTP mocking and expectations library for Node.js

Annotations
@RawJSType() @native()
Linear Supertypes
Object, Any, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Nock
  2. Object
  3. Any
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def activeMocks(): Array[String]

    Permalink

    You can see every mock that is currently active (i.e.

    You can see every mock that is currently active (i.e. might potentially reply to requests) in a scope using scope.activeMocks(). A mock is active if it is pending, optional but not yet completed, or persisted. Mocks that have intercepted their requests and are no longer doing anything are the only mocks which won't appear here. You probably don't need to use this - it mainly exists as a mechanism to recreate the previous (now-changed) behavior of pendingMocks().

    returns

    the array of active mocks

  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def basicAuth(options: |[NockBasicAuth, Any]): Nock.this.type

    Permalink

    Basic authentication can be specified

    Basic authentication can be specified

    options

    the basic authentication options

  7. def cleanAll(): Nock.this.type

    Permalink

    You can cleanup all the prepared mocks (could be useful to cleanup some state after a failed test)

  8. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. def delay(options: |[NockDelayBody, Any]): Nock.this.type

    Permalink

    You are able to specify the number of milliseconds that the response body should be delayed.

    You are able to specify the number of milliseconds that the response body should be delayed. Response header will be replied immediately. delayBody(1000) is equivalent to delay({body: 1000}).

    options

    an object containing the delay in milliseconds

  10. def delayBody(millis: Int): Nock.this.type

    Permalink

    You are able to specify the number of milliseconds that the response body should be delayed.

    You are able to specify the number of milliseconds that the response body should be delayed. Response header will be replied immediately. delayBody(1000) is equivalent to delay({body: 1000}).

    millis

    the given delay in milliseconds

  11. def delete(uri: Any): Nock.this.type

    Permalink

    HTTP DELETE

    HTTP DELETE

    uri

    the given url

  12. def disableNetConnect(host: Any = js.native): Nock.this.type

    Permalink

    By default, any requests made to a host that is not mocked will be executed normally.

    By default, any requests made to a host that is not mocked will be executed normally. If you want to block these requests, nock allows you to do so.

    For disabling real http requests.

  13. def enableNetConnect(host: Any = js.native): Nock.this.type

    Permalink

    For enabling real HTTP requests (the default behaviour).

  14. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  16. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. def get(uri: Any): Nock.this.type

    Permalink

    HTTP GET

    HTTP GET

    uri

    the given url

  18. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  19. def hasOwnProperty(v: String): Boolean

    Permalink
    Definition Classes
    Object
  20. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  21. def head(uri: Any): Nock.this.type

    Permalink

    HTTP HEAD

    HTTP HEAD

    uri

    the given url

  22. def isDone(): Boolean

    Permalink

    You can call isDone() on a single expectation to determine if the expectation was met

    You can call isDone() on a single expectation to determine if the expectation was met

    returns

    true, if the expectation was met

  23. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  24. def isPrototypeOf(v: Object): Boolean

    Permalink
    Definition Classes
    Object
  25. def load(pathToJson: String): Object

    Permalink

    If you save this as a JSON file, you can load them directly through nock.load(path).

    If you save this as a JSON file, you can load them directly through nock.load(path). Then you can post-process them before using them in the tests for example to add them request body filtering (shown here fixing timestamps to match the ones captured during recording)

    pathToJson

    the path to the JSON file

    returns

    the loaded object

  26. def log(logger: Any): Nock.this.type

    Permalink

    Nock can log matches if you pass in a log function

    Nock can log matches if you pass in a log function

    logger

    the given logger function

    Example:
    1. Nock.log(console.log)
  27. def matchHeader(key: String, value: Any): Nock.this.type

    Permalink
  28. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  29. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  30. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  31. def once(): Nock.this.type

    Permalink
  32. def optionally(): Nock.this.type

    Permalink
  33. def patch(uri: String, body: Any = js.native): Nock.this.type

    Permalink

    HTTP PATCH

    HTTP PATCH

    uri

    the given url

  34. def pendingMocks(): Array[String]

    Permalink

    You can inspect the scope to infer which ones are still pending

    You can inspect the scope to infer which ones are still pending

    returns

    the array of pending mocks

  35. def persist(): Nock.this.type

    Permalink

    You can make all the interceptors for a scope persist by calling .persist() on it

    You can make all the interceptors for a scope persist by calling .persist() on it

    returns

    self

  36. def post(uri: String, body: Any = js.native): Nock.this.type

    Permalink

    HTTP POST

    HTTP POST

    uri

    the given url

  37. def propertyIsEnumerable(v: String): Boolean

    Permalink
    Definition Classes
    Object
  38. def query(params: Any): Nock.this.type

    Permalink
  39. def recorder: NockRecorder

    Permalink

    This is a cool feature: Guessing what the HTTP calls are is a mess, specially if you are introducing nock on your already-coded tests.

    This is a cool feature: Guessing what the HTTP calls are is a mess, specially if you are introducing nock on your already-coded tests. For these cases where you want to mock an existing live system you can record and playback the HTTP calls like this:

    returns

    the recorder instance

  40. def removeInterceptor(options: |[NockInterceptorOptions, Any] = js.native): Nock.this.type

    Permalink
  41. def reply(statusCode: Int, response: Any = js.native): Nock.this.type

    Permalink
  42. def replyWithError(error: Any): Nock.this.type

    Permalink
  43. def restore(): Nock.this.type

    Permalink

    You can restore the HTTP interceptor to the normal unmocked behaviour

  44. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  45. def thrice(): Nock.this.type

    Permalink
  46. def times(count: Int): Nock.this.type

    Permalink
  47. def toLocaleString(): String

    Permalink
    Definition Classes
    Object
  48. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  49. def twice(): Nock.this.type

    Permalink
  50. def valueOf(): Any

    Permalink
    Definition Classes
    Object
  51. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  52. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  53. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Object

Inherited from Any

Inherited from AnyRef

Inherited from Any

Ungrouped