Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing components #34

Closed
carlesba opened this issue Jul 16, 2018 · 1 comment
Closed

Testing components #34

carlesba opened this issue Jul 16, 2018 · 1 comment
Labels
question Further information is requested

Comments

@carlesba
Copy link

How can you test a component that uses a Constate Container?

I've found some issues testing child-as-function with Enzyme. Do you have any strategy for it?

@diegohaz diegohaz added the question Further information is requested label Jul 16, 2018
@diegohaz
Copy link
Owner

diegohaz commented Jul 16, 2018

Hey, @carlesba.

My approach is usually to not test presentational components. Even at Facebook they don't do as much, as Dan said on this Q&A:

Personally I don't find unit testing components very valuable. Especially if they just contain markup — you're basically testing that React works, and we have tests in React itself for that. I think some combination of integration tests for higher-level UI scenarios (click a button, something shows up) and unit tests for logic (e.g. complex calculations) is helpful. I'm more skeptical of asserting on component output although I understand others might not agree.

If this is about components, I’ll reiterate we don’t do that much unit testing of components at Facebook.

I particularly didn't have problems on testing render props with Enzyme. They currently don't support the new Context API though (the PR was merged, but not yet released).

What I highly recommend you to do is testing containers or using react-testing-library instead of Enzyme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants