Replies: 1 comment 1 reply
-
Here’s my approach at testing react query: https://tkdodo.eu/blog/testing-react-query |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
If I have a project that depends on a separate
@shared/api
package that contains various custom query hooks, what would be the recommended approach to testing components that use those hooks without needing to know too much about the internals of the hook?For example, suppose I have these two packages and modules:
Then in a test for the
PostPreview
component, I would like to mock theusePost
hook without needing to know more than it's public interface: the hook's inputs and outputs.Can I mock
usePost
without knowing it's API endpoint path or the name of it's internal query function?I realize that this may be a challenge of hooks in general, but it is more striking with React Query's hooks because they do so much underneath that just mocking the output would be very limiting. I'm wondering if anybody using RQ has encountered this problem and if there's an obvious solution that I'm not seeing.
Beta Was this translation helpful? Give feedback.
All reactions