You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
B is smart component which in its componentDidMount, it fetch data from endpoint using axios or rxjs ajax. How do you intercept the request to return fake data. I do not want it to hit the real endpoint
The text was updated successfully, but these errors were encountered:
One option is to mock out the library you are using a require-time mock. This is sort of brittle though.
A better option is to have your B component take its async library from the context, e.g. this.context.axios. You can make it default to requiring axios if the context is unset if you want it to be easily consumable. Then you can use a mocked axois provider when testing.
Without sandbox, this injection stays and influences other tests. So make sure you also use stub with sandbox. https://sinonjs.org/releases/v1.17.7/sandbox/
I used sandbox on before() and after(), but since you are doing this for storybook, you could do the same on lifecycle hooks.
I wonder how you write storybook for this case
B is smart component which in its componentDidMount, it fetch data from endpoint using axios or rxjs ajax. How do you intercept the request to return fake data. I do not want it to hit the real endpoint
The text was updated successfully, but these errors were encountered: