Skip to content

Conversation

sukvvon
Copy link
Contributor

@sukvvon sukvvon commented Jul 25, 2025

No description provided.

Copy link

nx-cloud bot commented Jul 25, 2025

View your CI Pipeline Execution ↗ for commit 0e22231

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 53s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2025-07-26 13:05:49 UTC

Copy link

pkg-pr-new bot commented Jul 25, 2025

More templates

@tanstack/angular-query-devtools-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-devtools-experimental@9494

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@9494

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@9494

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@9494

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@9494

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@9494

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@9494

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@9494

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@9494

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@9494

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@9494

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@9494

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@9494

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@9494

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@9494

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@9494

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@9494

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@9494

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@9494

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@9494

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@9494

commit: 0e22231

Copy link

codecov bot commented Jul 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.20%. Comparing base (52fdff2) to head (86ac032).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #9494       +/-   ##
===========================================
+ Coverage   45.30%   89.20%   +43.89%     
===========================================
  Files         208       18      -190     
  Lines        8283      176     -8107     
  Branches     1862       31     -1831     
===========================================
- Hits         3753      157     -3596     
+ Misses       4085       18     -4067     
+ Partials      445        1      -444     
Components Coverage Δ
@tanstack/angular-query-devtools-experimental ∅ <ø> (∅)
@tanstack/angular-query-experimental ∅ <ø> (∅)
@tanstack/eslint-plugin-query ∅ <ø> (∅)
@tanstack/query-async-storage-persister ∅ <ø> (∅)
@tanstack/query-broadcast-client-experimental ∅ <ø> (∅)
@tanstack/query-codemods ∅ <ø> (∅)
@tanstack/query-core ∅ <ø> (∅)
@tanstack/query-devtools ∅ <ø> (∅)
@tanstack/query-persist-client-core ∅ <ø> (∅)
@tanstack/query-sync-storage-persister ∅ <ø> (∅)
@tanstack/query-test-utils ∅ <ø> (∅)
@tanstack/react-query ∅ <ø> (∅)
@tanstack/react-query-devtools ∅ <ø> (∅)
@tanstack/react-query-next-experimental ∅ <ø> (∅)
@tanstack/react-query-persist-client ∅ <ø> (∅)
@tanstack/solid-query ∅ <ø> (∅)
@tanstack/solid-query-devtools ∅ <ø> (∅)
@tanstack/solid-query-persist-client ∅ <ø> (∅)
@tanstack/svelte-query 87.58% <ø> (ø)
@tanstack/svelte-query-devtools ∅ <ø> (∅)
@tanstack/svelte-query-persist-client 100.00% <ø> (ø)
@tanstack/vue-query ∅ <ø> (∅)
@tanstack/vue-query-devtools ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

await vi.advanceTimersByTimeAsync(0)
expect(rendered.getByText('Status 1: pending')).toBeInTheDocument()
expect(rendered.getByText('Status 2: pending')).toBeInTheDocument()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If queryFn's sleeping time is different, it would be better to add test code for the case after just 10ms, not only this.

Comment on lines 25 to 55
await sleep(5)
return 'Success 1'
},
queryFn: () => sleep(10).then(() => 'Success 1'),
},
{
queryKey: ['key-2'],
queryFn: async () => {
await sleep(5)
return 'Success 2'
},
queryFn: () => sleep(20).then(() => 'Success 2'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If queryFn's sleeping time is different 10ms, 20ms, it would be better to add test code for the case after just 10ms, not only for case after 20ms.

Copy link
Contributor Author

@sukvvon sukvvon Jul 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If queryFn's sleeping time is different 10ms, 20ms, it would be better to add test code for the case after just 10ms, not only for case after 20ms.

@manudeli

That makes sense. I’ll add the test as you suggested.

@sukvvon sukvvon force-pushed the test/svelte-query-createQueries-use-precise-time-advanceTimersByTimeAsync-simplify-queryFn branch from eed9a97 to f2d7746 Compare July 26, 2025 05:44
@sukvvon sukvvon requested a review from manudeli July 26, 2025 05:50
…time-advanceTimersByTimeAsync-simplify-queryFn
@sukvvon sukvvon marked this pull request as draft July 26, 2025 06:35
@sukvvon sukvvon changed the title test(svelte-query/createQueries): simplify 'queryFn' and use precise time in 'advanceTimersByTimeAsync' test(svelte-query/createQueries): simplify 'queryFn' and add test for success when queries reslove at different times Jul 26, 2025
Comment on lines +44 to +71
test('Render and wait for success when queries resolve at different times', async () => {
const rendered = render(BaseExample, {
props: {
options: {
queries: [
{
queryKey: ['key-1'],
queryFn: () => sleep(10).then(() => 'Success 1'),
},
{
queryKey: ['key-2'],
queryFn: () => sleep(20).then(() => 'Success 2'),
},
],
},
queryClient: new QueryClient(),
},
})

expect(rendered.getByText('Status 1: pending')).toBeInTheDocument()
expect(rendered.getByText('Status 2: pending')).toBeInTheDocument()

await vi.advanceTimersByTimeAsync(11)
expect(rendered.getByText('Status 1: success')).toBeInTheDocument()
await vi.advanceTimersByTimeAsync(10)
expect(rendered.getByText('Status 2: success')).toBeInTheDocument()
})

Copy link
Contributor Author

@sukvvon sukvvon Jul 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If queryFn's sleeping time is different 10ms, 20ms, it would be better to add test code for the case after just 10ms, not only for case after 20ms.

@manudeli

I added the test as you suggested.

@sukvvon sukvvon marked this pull request as ready for review July 26, 2025 13:03
…time-advanceTimersByTimeAsync-simplify-queryFn
@manudeli manudeli merged commit e9d9080 into TanStack:main Jul 26, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants