-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
test(react-query/useSuspenseQueries): use precise time in 'advanceTimersByTimeAsync', and add 'expect' using 'toBeInTheDocument' #9450
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
Conversation
…ersByTimeAsync', and add 'expect' using 'toBeInTheDocument'
View your CI Pipeline Execution ↗ for commit bdf6688
☁️ Nx Cloud last updated this comment at |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9450 +/- ##
===========================================
+ Coverage 45.30% 84.38% +39.07%
===========================================
Files 208 26 -182
Lines 8283 365 -7918
Branches 1865 107 -1758
===========================================
- Hits 3753 308 -3445
+ Misses 4085 48 -4037
+ Partials 445 9 -436 🚀 New features to boost your workflow:
|
…ise-time-advanceTimersByTimeAsync
…ise-time-advanceTimersByTimeAsync
@@ -311,7 +311,7 @@ describe('useSuspenseQueries 2', () => { | |||
|
|||
const { data } = useSuspenseQuery({ | |||
queryKey: [id], | |||
queryFn: () => Promise.resolve(`Data ${id}`), | |||
queryFn: () => sleep(10).then(() => `Data ${id}`), |
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.
👍
await act(() => vi.advanceTimersByTimeAsync(200)) | ||
rendered.getByText('loading') | ||
// unmount while still fetching | ||
expect(rendered.getByText('loading')).toBeInTheDocument() | ||
fireEvent.click(rendered.getByText('hide')) | ||
await act(() => vi.advanceTimersByTimeAsync(800)) | ||
rendered.getByText('page2') | ||
expect(rendered.getByText('page2')).toBeInTheDocument() | ||
// wait for query to be resolved | ||
await act(() => vi.advanceTimersByTimeAsync(2000)) |
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.
👍👍👍
await sleep(10) | ||
return 'data' + count | ||
}, | ||
queryFn: async () => sleep(10).then(() => 'data' + count), |
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.
queryFn: async () => sleep(10).then(() => 'data' + count), | |
queryFn: () => sleep(10).then(() => 'data' + count), |
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.
I missed this. I gonna fix this next time
No description provided.