Module: models/stubRepository

Maintains all stubs for an imposter

Source:

Members

(constant) stubs :Array

The list of stubs within this repository

Type:
  • Array
Source:

Methods

addStub(stub, beforeResponse)

Adds a stub to the repository

Parameters:
Name Type Description
stub Object

The stub to add

beforeResponse Object

If provided, the new stub will be added before the stub containing the response (used for proxyOnce)

Source:

addStubAtIndex(index, newStub)

Adds a stub at stubIndex without changing the state of any other stubs

Parameters:
Name Type Description
index Number

the index of the stub to change

newStub Object

the new stub

Source:

deleteStubAtIndex(index)

Deletes the stub at stubIndex without changing the state of any other stubs

Parameters:
Name Type Description
index Number

the index of the stub to remove

Source:

getResponseFor(request, logger, imposterState) → {Object}

Finds the next response configuration for the given request

Parameters:
Name Type Description
request Object

The protocol request

logger Object

The logger

imposterState Object

The current state for the imposter

Source:
Returns:
  • Promise resolving to the response
Type
Object

getStubs() → {Object}

Returns the outside representation of the stubs

Source:
Returns:
  • The stubs
Type
Object

overwriteStubAtIndex(index, newStub)

Overwrites the stub at stubIndex without changing the state of any other stubs

Parameters:
Name Type Description
index Number

the index of the stub to change

newStub Object

the new stub

Source:

overwriteStubs(newStubs)

Overwrites the entire list of stubs

Parameters:
Name Type Description
newStubs Object

the new list of stubs

Source:

(inner) create(encoding) → {Object}

Creates the repository

Parameters:
Name Type Description
encoding string

utf8 or base64

Source:
Returns:
Type
Object