Closed jeco123 closed 4 months ago
Right now, the most useful way to test a mitosis component is to:
At Builder, we have a playwright integration tests suite that runs in parallel against multiple servers, each importing a different Mitosis output.
@samijaber I guess it's not possible to use something like Storybook React as JSX lite won't be supported / cause problems?
Currently I am testing it with webapps for React/Vue/Angular as those are the outputs we want to support. Having to set up our own test apps + build/watch scripts for HMR is fine as long as it's to verify the output and testing framework specific implementations. But having it as a debug/test while still developing the mitosis component (my-component.lite.tsx
) is tedious as:
Having something like storybook for mitosis would solve most of these issues and provide a better DX.
having something like storybook for mitosis
That is technically impossible because Mitosis is not a rendering framework or a runtime. The Mitosis JSX syntax is merely a parser from JSX to JSON. There is no "Mitosis component" to render.
The only way to test Mitosis content is to render it using one an actual web framework. You are already doing that.
debug info such as console statements are removed in the compiler
You can try the onInit
hook to do some debugging. it's not perfect, and not all outputs support it, but it's one solution: https://mitosis.builder.io/playground/?code=JYWwDg9gTgLgBAbzhAdgSRceBfOAzKCEOAIgAEAjAV2ABsATAUygDpgIB6ELCAZ2F4kA3ACgRjAB6RYcJngCGVWvDxUUAYxjsUcALIBPAMJFIKRihgAKMITC8AlIjFxk6TFcuOAvAD4nLl3VUXghaRhZaCABzSwByAAtGWki4AHdoBlj7ERdsbJy4KEYYKigdSwKXAB56YAA3HwAJJMiqjlqGgvtRbCA
I typically add hooks like onUpdate
to add logs if I need to.
I will close this issue as there is nothing actionable that can be done about it at this point.
I am interested in helping provide a feature!
Yes
Which generators are impacted?
What problem does this feature solve?
I would like to develop my components using the TDD approach. It is necessary for me to have a test environement that can interpret a "mitosis component" in order to implement a test first and implement the code at a second time.
What does the proposed API look like?
I like the Stencil approach with their test environment.
Could be great to develop this kind of stuff.
Additional Information
No response