Mocks delete requests. Works analog to onGetReply().
Optional
url: stringMocks response exceptions for delete methods. It works like onDeleteReply(), but throws an HttpError instead
Mocks responses for get methods You may pass a specific endpoint as parameter to mock only selected endpoints. This is very useful, when having methods that do several Http requests, so you can mock them one on one.
The following code returns the same content on every get call
HttpMockBuilder
.create()
.onGetReply(200, {response: 'foo}) // mocks all get requests
.onPostReply(201, {response: 'foo}) // mocks all post requests
.build()
The next code returns the different content depending on the passed endpoint
HttpMockBuilder
.create()
.onGetReply(200, {response: 'foo}, '/url/specific') // mocks get request for '/url/specific'
.build()
{number} The status to be returned
The data to be returned
Optional
url: string{string?} If given, the mock applies for that specific url, other for all method calls
The builder instance (Fluent API)
Mocks response exceptions for get methods. It works like onGetReply(), but throws an HttpError instead
{number} The status to be returned in exception object
{string} The error message
{any?} Eventual data carried with the error object
{string?} The specific url for which the exception should be thrown
The builder instance (Fluent API)
Mocks post requests. Works analog to onGetReply().
Optional
url: stringMocks response exceptions for post methods. It works like onPostReply(), but throws an HttpError instead
Mocks put requests. Works analog to onGetReply().
Optional
url: stringMocks response exceptions for put methods. It works like onPutReply(), but throws an HttpError instead
Static
createCreates a builder instance
the builder
Builds the Http mock.