Options
Last updated
Last updated
You can use the following options to provide in the MockConfig
object of your main.ts
file:
enableWorker
boolean
true
yes
General Boolean to enable / disable the Mock Server. Can be connected to a property within the environment
environment
Environment
yes
Your Angular environment file. This is needed so the mock Server can read the occ baseUrl
and prefix
When running ng add @valantic/spartacus-mock
, your environment file get's enhanced with some properties needed for the mock-server.
enableDefaultData
boolean
true
no
Allows to enable / disable adding the default Handlers for the spartacus default API requests. At the begin of your project you want this to have a starting point. Further down the road, when everything is mocked, you can disable it to save some bytes
passThroughRequests
Array<MockRequest>
undefined
no
Allows to define an array of MockRequest
objects, which should be ignored and passed through by the mock server
handlers
Array<RestHandler>
undefined
no
Allows to define an array of mws for default or custom OCC Endpoints
contentPages
ContentPages
undefined
no
Allows to define an Object containing Spartacus Page
objects. The keys of the object properties correspondent to the page label in the browser
productDetailPage
Page
undefined
no
Allows to define an Spartacus Page
object to be used as Product Page
productCategoryPage
Page
undefined
no
Allows to define an Spartacus Page
object to be used as Product Category Page
homePage
Page
undefined
no
Allows to define an Spartacus Page
object to be used as Home Page
customSlots
Array<Occ.ContentSlot>
undefined
no
Allows to define an Array of Spartacus Occ.ContentSlot
Objects to be used for the global Header / Footer slots.
translations
TranslationResources
undefined
no
Allows to provide an TranslationResources
Object containing translation overrides for the Spartacus default translations, custom chunks for the translations or even whole custom languages.
inclusionMode
boolean
false
no
Allows to run the mock server in a Inclusion Mode without using any default Request Handlers. This is useful for existing Projects, where only specific Elements (Pages / Slots / Components) should be mocked.
mockedRequests
Array<MockRequest>
undefined
no
Allows to provide an array of MockRequest
objects which should be responded by the mock server. This is useful in combination with the Option inclusionMode
, where you only want to mock specific Requests. You will only see MSW Warnings for missing Handlers for URL's provided in this Array
mockedPageIds
Array<string>
undefined
no
Allows to provide an array of pageId (page label) strings which should be responded by the mock server. This is useful in combination with inclusionMode
, where you only want to mock e.g. specific pages
quit
boolean
undefined
no
Allows to disable any console log output from mws. Sets the Option worker.quite of mws
debug
boolean
undefined
no
Allows to get some more debugging information in the browser console. Currently, the only additional information is the list of active Request handlers.