-
Notifications
You must be signed in to change notification settings - Fork 36
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 test the client with Jest? #81
Comments
Hi Blake, You could use Alternatively (and this is what I would recommend) you could switch over to an integration testing approach - we are using Playwright and it is working great for us: https://github.com/apollographql/apollo-client-nextjs/tree/main/integration-test |
One more idea: you could try to start jest with a node resolution condition to favor node --conditions=react-server path/to/jest ... (Note: I haven't tested this and I don't know if jest maybe overwrites this node behaviour.) |
Thanks for your response @plausible-phry! Playwright has been on my mind lately, maybe its time to make the switch. |
I'm doing some housekeeping so I'm closing some older issues that haven't seen activity in a while. |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better. |
Hi y'all, thank you for this package! I'm excited to see support coming for the app router. I was curious how I could go about testing the client in Jest? It seems I get an error because I'm not in the proper server context (
createContext
exists onreact
):However, it doesn't seem there is any way to control this from a testing perspective. For example, here is a simplified test that tries to ensure the http link is called with the appropriate uri:
Obviously this is a simplified test, but we are building a framework on top of this experimental package, and having a way to test these things would be extremely helpful.
Any guidance would be appreciated!
The text was updated successfully, but these errors were encountered: