teambit / bit

A build system for development of composable software.

Home Page:https://bit.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mocking for previews

opensean opened this issue · comments

commented

Description

What is the recommenced way to mock functions in a fixture so previews render without errors? For example, if I have a vue component that makes a call to an external API, is it possible to mock that call in a fixture so the preview can render in bit.cloud? I understand that there is way to modify the context for previews at the environment level here https://bit.dev/docs/vue-env/component-previews. However, I feel like i should be able to do this at the component level, otherwise, i will need to create new envs for each component. I think my question is similar to this one #4692. I am still learning bit so any guidance is appreciated. Thank you.

Specifications

Just following the examples in the https://bit.dev/docs/vue-intro documentation.

Context and additional information

Just following the examples in the https://bit.dev/docs/vue-intro documentation.

whenever dealing with external services/api, we found that creating a component to align with that service on the type of data shared, providing a class and even serialize/de-serialize functions is a good architecture pattern. that component may also hold mock-data, so any consuming frontend that wants to run tests or even render without data-fetching gets some mocks.

i made a webinar on the topic - https://www.youtube.com/watch?v=tUGB5UKIOrY

commented

@itaymendel this pattern makes sense, thank you for the clarification.