Constructor
new MockServer(options)
Sets properties needed internally
- factoryFarm: a pre-existing factory to use on this server
- responseOverrides: An array of alternative responses that can be used to override the ones that would be served from the internal store.
Name | Type | Description |
---|---|---|
options | object | currently |
- Source
Methods
add(name, options) → {*}
Alias for this._backendFactoryFarm.add
Name | Type | Description |
---|---|---|
name | string | the name to use for the factory |
options | object | properties and other options for adding a model to the store |
- Source
Object or Array
- Type:
- *
build(factoryName, overrideOptions, numberOfRecords) → {*}
Alias for this._backendFactoryFarm.build
Name | Type | Description |
---|---|---|
factoryName | string | the name of the factory to use |
overrideOptions | object | overrides for the factory |
numberOfRecords | number | optional number of models to build |
- Source
Object or Array
- Type:
- *
define(name, options) → {*}
Alias for this._backendFactoryFarm.define
Name | Type | Description |
---|---|---|
name | string | the name to use for the factory |
options | object | options for defining a factory |
- Source
Object or Array
- Type:
- *
respond(options)
Adds a response override to the server
Name | Type | Description |
---|---|---|
options | object | path, method, status, and response to override
|
- Source
start(options)
Sets up fetch mocking to intercept requests. It will then either use overrides, or use its own internal store to simulate serving JSON responses of new data.
- responseOverrides: An array of alternative responses that can be used to override the ones that would be served from the internal store.
- factoriesForTypes: A key map that can be used to build factories if a queried id does not exist
Name | Type | Description |
---|---|---|
options | object | currently |
- Source
stop()
Clears mocks and the store
- Source