How to unit test components? #3651
Unanswered
Victor-N-Suadicani
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like to unit test my components, but I'm not sure exactly how to achieve that.
What I would like to do is to obtain a
Context<Self>
and then just callComponent::create
. Then I would haveSelf
and I could callComponent::view
and start inspecting the HTML to check if it contains what I want. Then I could even start sending messages viaComponent::update
and callComponent::view
again to check that it does what I wanted.However, I see no way to construct a
Context
in yew. Is there some other way to achieve what I want?I guess a problem as well is that if the component uses web_sys stuff, then I'm not at all sure how that would be provided to the code during testing.
What is the strategy for unit tests for components? Is it just not possible and I'll need to go for some form of end-to-end testing using browser testing like Cypress or something?
Beta Was this translation helpful? Give feedback.
All reactions