-
Notifications
You must be signed in to change notification settings - Fork 674
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
Expose selector dependencies for testing purposes #251
Conversation
Codecov Report
@@ Coverage Diff @@
## master #251 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 1 1
Lines 15 15
=====================================
Hits 15 15
Continue to review full report at Codecov.
|
Any updates on this PR? Are the maintainers absent? |
Would love to have that feature too. |
What does everyone think of this? |
merge! 🚢 |
Just ran into the same issue myself, so this would be super helpful. Merge! |
Merge! 👍 |
Wooohoooo! I can't believe I didn't see this. This will allow me to remove a step from installing the reselect developer tools |
Did this get merged? |
@ellbee @alex3165 @markerikson can y'all take a look at this to see if we can merge it? |
@ellbee could you take a look at this? It would be really handy to have in |
Ok, this is not something that has been a pain point for me but seems to be for others so lets merge it in! |
Has this change been published? I see it in master but not in my node_modules. |
I do not see that there is a necessity to mock the dependencies of the selector and test the only resultFunction.
Are getPlanningAssignmentTabZoomLevel and getProjectAssignmentsByProjectId real dependencies for the main selector? I do not think so, since it's a pure function and does not have side effects, basically, you can copy the code of this function and put inside the selector. However, if you mock getPlanningAssignmentTabZoomLevel you rely on the code inside of the selector, I do not think that it's a good approach to test the technical implementation rather than test what the selector should do. As an example of the correct test approach, please find my test. I used the BDD (Behavior-Driven Development) approach.
Instead of mock function |
This PR allows us to test which dependencies are passed into a selector.
Original conversation: #76 (comment)
It matters which dependencies a selector uses. For example, if we have two selectors that use the same
resultFunc
......testing the
resultFunc
isn't enough. We actually need to test that the first two functions are what we expect them to be. We can do this with an integration test (passing in the entire state into the whole selector) but, it forces us to essentially re-testgetMyHash
,getMyIds
.Desired API
We've been running into this problem. The direction I'm leaning is to expose the dependencies so that we can test them with a simple equality check.