docs: add guidance on testing suspense hooks with MockedProvider#13291
Conversation
|
@copilot: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/ |
✅ Docs preview readyThe preview is ready to be viewed. View the preview File Changes 0 new, 1 changed, 0 removedBuild ID: c25e1f72d733e716f5692547 URL: https://www.apollographql.com/docs/deploy-preview/c25e1f72d733e716f5692547
|
|
Co-authored-by: phryneas <4282439+phryneas@users.noreply.github.com>
Co-authored-by: phryneas <4282439+phryneas@users.noreply.github.com>
commit: |
Components using
useSuspenseQuerypermanently hang in tests withMockedProviderunlessrenderis wrapped inawait act(). UnlikeuseQuery, suspense hooks suspend the component immediately — the test never advances withoutactto drive React through the suspend/resume cycle.Changes
docs/source/development-testing/testing.mdx— adds a "Testing with Suspense" section explaining the behavioral difference betweenuseQueryanduseSuspenseQueryin tests, with a full working example:Without
await act(), theSuspensefallback renders and never resolves. This is not aMockLinkbug — Apollo'sSuspenseCachekeeps the subscription alive; the missing piece isactto let React process the suspend/resume cycle.