-
Notifications
You must be signed in to change notification settings - Fork 35
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 can I writing specs for a component using "useReadQuery" #354
Comments
Hi @EfstathiadisD! The That said, I wouldn't try to replicate all of that in a test ;) Instead, you can create a real That could look like this: const mockLink = new MockLink([
/* Your mocks here */
]);
const client = new ApolloClient({
link: mockLink,
cache: new InMemoryCache(),
})
const preloader = createQueryPreloader(client);
const queryRef = preloader(query, { variables: { id: 1 } });
We're removing |
Thanks! That solve the issue. |
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. |
I have a Server and Client component combo. The server has the following..
The Client is reading it..
That works as expected. Now I am trying to write some tests.. I am using MockProvider and when I am passing the following object as queryRef to the component which I copy pasted from the console. I get the error..
I tried a few cause it seems what I get on the server is different from the one on the client.
The ProfileDocument is correct. I checked. I am not sure of two things..
It would be nice if someone can link to an example where such specs are written or a README as I couldn't find anything in the DOCS. Thank y!
PS: There is some warning re. the
toPromise()
with NextJS as well. It tells me that it should pass pure objects btwn Client and Server components. And toPromise() isn't as far as I can tell. It works on runtime, but I am thinking this isn't what I am mocking correct since it could be far more complicated that it looks on the surface. Maybe wrong?The text was updated successfully, but these errors were encountered: