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

How to write tests with Provider #550

Closed
bstro opened this issue Feb 20, 2020 · 2 comments · Fixed by #554
Closed

How to write tests with Provider #550

bstro opened this issue Feb 20, 2020 · 2 comments · Fixed by #554
Labels
documentation 📖 This needs to be documented but won't need code changes

Comments

@bstro
Copy link

bstro commented Feb 20, 2020

Is there any documentation for how to write tests for components that make calls to useQuery and useMutation?

What should I use in tests since the entire app is wrapped in urql's Provider? In tests, I need access to that context, but I need the ability to provide it mocked data. apollo-client offers a MockedProvider which takes a mocks prop that I can provide mocked data, but I'm not quite sure what to do in the case of urql.

@bstro bstro changed the title Testing How to write tests with Provider Feb 20, 2020
@JoviDeCroock
Copy link
Collaborator

JoviDeCroock commented Feb 20, 2020

Hey @bstro

I’ve heard about this exchange being used to test. This creates your own miniature resolver. I’m thinking if we can abstract it further but personally I think it’s a good start.

Hope this helps you out, feel free to express any concerns you have with that approach.

We're also working on integrating a similar solution: #474

@andyrichardson
Copy link
Contributor

Funny (or suspicious) that you should ask this, keep your eyes peeled for new docs on testing some time today.

@andyrichardson andyrichardson added the documentation 📖 This needs to be documented but won't need code changes label Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation 📖 This needs to be documented but won't need code changes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants