Create a list of responses (by providing an array), or a single repeating response (by providing any other type). 'Name' is optional and used in error messages.
Get the next configured response. Throws an error when configured with a list of responses and no more responses remain.
The next response.
Static
createCreate a list of responses (by providing an array), or a single repeating response (by providing any other type). 'Name' is optional and used in error messages.
Static
mapConvert all properties in an object into ConfigurableResponse instances. For example, { a: 1 } becomes { a: ConfigurableResponses.create(1) }. 'Name' is optional and used in error messages.
An object with single response or an array of responses.
Optional
name: stringAn optional name for the responses.
Handle returning pre-configured responses.
This is one of the nullability patterns from James Shore's article on testing without mocks.
Example usage for stubbing
fetch
function: