Test Next.js app with useSWR hook to fetch data from GraphQL server #9124
Unanswered
masakudamatsu
asked this question in
Questions and Help
Replies: 1 comment 3 replies
-
Please set up a repo with reproduction we can run. I have tested SWR hook in https://github.com/bahmutov/test-swr but as a component test. |
Beta Was this translation helpful? Give feedback.
3 replies
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.
-
Hi. My app is built with Next.js and uses the useSWR hook to fetch data from my own GraphQL server (running on
localhost:4000
). I want to test if clicking the submit button will show a new element rendered with the fetched data.I code my test like this (I'm using cypress-testing-library to query for an element):
Even though the App preview does show the fetched data rendered as a new element, the test fails with this error:
I’ve been searching for a solution with Google but I cannot find any. Does anyone have an idea to make this test work?
Beta Was this translation helpful? Give feedback.
All reactions