This repository has been archived by the owner on May 2, 2023. It is now read-only.
Await an act in generateSnapshots to resolve warnings #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
An Apollo update in Along resulted in new warnings:
This is a known issue. Components that include Apollo's
useQuery
should await an act that pushes the test to the end of the event loop before they are tested. This change was also required ingenerateSnapshots
so when components that use theuseQuery
hook are passed to it, they are rendered correctly before we're taking a snapshot.Validation
I validated this fix manually by linking the library to the Along repo and running our test suite. I know that we're using
generateSnapshots
in traject as well, but it seems like it doesn't use Apollo so this should not have any impact (I haven't verified it because I don't have traject running locally).References
https://trojanowski.dev/apollo-hooks-testing-without-act-warnings/
https://reactjs.org/docs/test-utils.html#act
enzymejs/enzyme#2073 (comment)
apollographql/apollo-client#5920