Replies: 1 comment 3 replies
-
This actually sounds like a fairly reasonable approach that would work for many test scenarios.
You're making good points and I think I agree: we should export
There isn't and to be frank we're currently experimenting with ways of testing components and even entire tea apps ourselves. Any insight is greatly appreciated and will help shape what this looks like.
Yes, that's the plan!
👍 I came to the same conclusion the other day. CCing @caarlos0 for his opinion on the matter. |
Beta Was this translation helpful? Give feedback.
-
I feel like I could be missing something, but I'm having a hard time testing individual bubbles/components. I want to keep testing as simple as possible, so I felt the best way would be to instantiate the component model, send an initializing message to
Update()
and callUpdate()
in a loop feeding any messages back intoUpdate()
until no commands are returned. I realize this isn't perfect, there are some edge cases with this, however, it has the nice property of being able to treat the component like a black box, send a sequence of messages to the component, and the assert the string output fromView()
.The problem I'm running into is that
tea.Batch()
returnsbatchMsg
, an unexported type. Though it represents[]tea.Msg
(something that is exported) I still can't type assert to the transitive representation, thus, I can't really test in the way I described.Testing with an entire
tea.Program
seems really heavy and would bring in a lot of complexities that I would like to avoid.I could craft all of the expected messages from sub components myself (this would be the closest testing approach to what I originally described), however, this level of mocking seems heavier than I'd like. For instance, If I have a component that uses other components (say a component that uses the progress-bar and spinner bubbles), I don't want to mock out the other component
Update()
calls (by ignoring the results and crafting my own messages, which means I need to craft progress-bar frame messages, spinner tick messages, etc) --I'd prefer to see what the effect on theView()
output from a small set of initializing messages and "see" how the system of components settles out... I don't see how to do this (in a straight forward way)....with the context explained, here's a few questions:
batchMsg
really need to be unexported? Is this really an internal concern to bubble tea? (if it was exported it would help me out a lot)program
concerns, such as signal handling, etc).Beta Was this translation helpful? Give feedback.
All reactions