-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Remove itAsync
part 2
#12207
base: main
Are you sure you want to change the base?
Remove itAsync
part 2
#12207
Conversation
|
✅ Docs preview readyThe preview is ready to be viewed. View the preview File Changes 0 new, 1 changed, 0 removed
Build ID: ad4f8568faeafa24b1288118 URL: https://www.apollographql.com/docs/deploy-preview/ad4f8568faeafa24b1288118 |
commit: |
8a7a769
to
3035297
Compare
c976713
to
6c82bf7
Compare
size-limit report 📦
|
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
6c82bf7
to
f2defe9
Compare
f2defe9
to
ba16e3d
Compare
}); | ||
|
||
return new ObservableStream( | ||
queryManager.watchQuery<any>(assign({ query, variables }, queryOptions)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as a note, we should probably get rid of lodash in a follow-up PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed
}; | ||
await expect(stream).toEmitError( | ||
new ApolloError({ | ||
graphQLErrors: [null as any], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have another test somewhere else that test handling of the message
for `null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not to my knowledge, but I was more focused on updating tests to ObservableStream
that I didn't pay attention if there was.
|
||
stream.unsubscribe(); | ||
|
||
await expect(stream).not.toEmitAnything(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests more our implementation of ObservableStream
than the underlying observable - I think we can skip this line
await expect(stream).not.toEmitAnything(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few more occurances on this, but trying to comment on that file almost crashes my browser, so I'll not mention them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in cfdffaf with a bit better way to check that polling queries are properly stopped after unsubscribing
expect(queryManager.mutationStore).toEqual({}); | ||
}); | ||
|
||
xit("should only refetch once when we store reset", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we change this to test.skip
while we're at it so we can find skipped tests more easily in the future?
xit("should only refetch once when we store reset", async () => { | |
it.skip("should only refetch once when we store reset", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I missed this when I went through this file.
resetStore(queryManager).then(resolve, reject); | ||
|
||
await resetStore(queryManager); | ||
// Ensure the promise doesn't reject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we end up with a promise that neither rejects nor resolves here? That would be a pretty critical memory leak 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It kind of looks that way. I'm going to leave this for now, but ultimately I think this test will disappear. Its testing fetchQuery
which is a private function 🤦♂️. I'd like to test this from an end user perspective. When that happens I'll refactor this to check it different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok even worse than I thought. This test is starting the fetch, then removing the query from this.queries
in QueryManager
, then calling resetStore
to make sure the in-flight request doesn't reject.
To be honest, I'm not entirely sure the situation this is trying to check against since end users won't at all be doing this in their own apps. I believe we reject promises if you cancel them in-flight, so I don't know this is an actual real-world situation 🤦♂️
|
||
await expect(stream).toEmitMatchedValue({ data }); | ||
|
||
const conditional = jest.fn(() => []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of this test is "also works with a conditional function that returns false",
, why does this return []
? 😢 (not yourfault, just venting!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This took a while to work through... I'm happy with your changes, but you've uncovered a bunch of tests that really need a rework at some point 😅
Continuation of #12182