valantic/spartacus-mock

Not really a issue but more of a question.

Opened this issue · 2 comments

Hi guys, I'm working in a project now using the Sparatacus, I found this library and I thought was promising but I was not able to get working yet, following the documentation but when I add the library to the project but not all the files listed that would change after that did not change I got the angular.json modified and the mockServiceworker.js only is that ok ? One more question is when I want to use one of the handles and mock data OOTB made by you guys, there is a service class or something to me point to in my feature to know that rather make the original request to the server then call the mock. The last thing I noticed even after added MockConfig on my main.ts I still not getting the [MSW] Mocking enabled when I'm running the spartacus project. Thank you so much.

Hi @cesarpatrick,
Which versions are you using for?

  1. node
  2. angular
  3. spartacus
  4. spartacus-mock

Did you run ng add @valantic/spartacus-mock? Did it show any errors in the console?

We have just published version 3.1.0 of spartacus-mock, working with the latest mws version, spartacus 6.7.0 and angular 15. The latest version adds more automatically generated files to help you getting started.

Out of the box, all requests for the standard electronics store https://spartacus-demo.eastus.cloudapp.azure.com/electronics-spa/en/USD/ are mocked.

After a successful setup, you should have several files being generated, see here: https://github.com/valantic/spartacus-mock/blob/main/docs/getting-started/installation.md

If the schematics (running ng add @valantic/spartacus-mock) do not work for you, you can aswell just run npm i -d @valantic/spartacus-mock@3.1.0 to install it and then copy / create the files manually.

You can also check this example project, this is how it should look like after the successful setup: https://github.com/janwidmer/spartacus-test-6.7.0/tree/main/src/mock-server. if you clone this test project, you should see spartacus-mock running:

  1. Checkout Repo
  2. Make sure, you run node version 18.18.0
  3. Run npm i
  4. Run npm run start
  5. Open Browser URL http://localhost:4200/electronics-spa/de/USD/

@cesarpatrick we have released another version having more detailed installation docs: https://valantic.gitbook.io/spartacus-mock/getting-started/installation