Terminology
Out of the box, spartacus-mock
comes with all** mock-data needed to run the spartacus electronics sample store. For your project, you probably want to define your own mock-data for the default endpoints of spartacus and also add custom Endpoints.
For every endpoint where you want to return custom data, you need to define a handler, which intercepts the call to the endpoint by listening for and matching to the route and returning mock-data. Every handler needs a route to intercept the call.
** "all" meaning all base commerce features. Check the Roadmap to see which feature libs are planned to add
Terminology | Explanation |
---|---|
Spartacus | The Angular Frontend Framework to Run SAP Commerce Websites. More information can be found here |
MSW | The underlying Tool doing the heavy work. More information can be found here |
Endpoint | An API URL of SAP Commerce to be called by spartacus. Default Endpoints are defined as part of Spartacus Core, Custom Endpoints an be added via |
Route | A string representing the url of an Endpoint. The route get's used by MSW to map Calls to handlers. The route string can be static or contain parameters or use a regex. More information can be found here. |
Handler | A javascript function to return the mock-data for a certain endpoint listening on a certain route. More information can be found here. |
mock-data | The mock-data to be returned by the Handler. The mock-date represents the data normally being returned by SAP Commerce |
Look at the examples to see the different ways to define mock-data.
Last updated