query icon indicating copy to clipboard operation
query copied to clipboard

test(solid-query/useQuery): migrate to fake timers with 'advanceTimersByTimeAsync', add 'expect().toBeInTheDocument()', convert sync 'queryFn' to 'sleep().then()', and add detailed timing comments

Open sukvvon opened this issue 2 months ago • 5 comments

🎯 Changes

✅ Checklist

  • [x] I have followed the steps in the Contributing guide.
  • [x] I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • [ ] This change affects published code, and I have generated a changeset.
  • [x] This change is docs/CI/dev-only (no release).

sukvvon avatar Nov 23 '25 10:11 sukvvon

⚠️ No Changeset found

Latest commit: 948599d8cf02cbe90ddaebd43bcab8ca5eb2cc68

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Nov 23 '25 10:11 changeset-bot[bot]

[!IMPORTANT]

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (1)
  • packages/solid-query/src/tests/useQuery.test.tsx

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Nov 23 '25 10:11 coderabbitai[bot]

View your CI Pipeline Execution ↗ for commit 948599d8cf02cbe90ddaebd43bcab8ca5eb2cc68

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

☁️ Nx Cloud last updated this comment at 2025-12-15 11:50:22 UTC

nx-cloud[bot] avatar Nov 23 '25 10:11 nx-cloud[bot]

More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@9894
@tanstack/eslint-plugin-query

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

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@9894
@tanstack/query-broadcast-client-experimental

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

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

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

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@9894
@tanstack/query-sync-storage-persister

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

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

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

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

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

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

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

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

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

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

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

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

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

commit: 948599d

pkg-pr-new[bot] avatar Nov 23 '25 10:11 pkg-pr-new[bot]

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 76.63%. Comparing base (f15b7fc) to head (948599d).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #9894       +/-   ##
===========================================
+ Coverage   45.89%   76.63%   +30.74%     
===========================================
  Files         200       19      -181     
  Lines        8437      398     -8039     
  Branches     1943       83     -1860     
===========================================
- Hits         3872      305     -3567     
+ Misses       4116       76     -4040     
+ Partials      449       17      -432     
Components Coverage Δ
@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 77.81% <ø> (ø)
@tanstack/solid-query-devtools 64.17% <ø> (ø)
@tanstack/solid-query-persist-client 100.00% <ø> (ø)
@tanstack/svelte-query ∅ <ø> (∅)
@tanstack/svelte-query-devtools ∅ <ø> (∅)
@tanstack/svelte-query-persist-client ∅ <ø> (∅)
@tanstack/vue-query ∅ <ø> (∅)
@tanstack/vue-query-devtools ∅ <ø> (∅)
:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Nov 23 '25 10:11 codecov[bot]

@TkDodo

I converted complex then callbacks (with multiple statements like variable increments, conditionals, or throws) to async/await pattern, while keeping simple one-liner then callbacks (e.g., sleep(10).then(() => 'data')) as-is for conciseness.

Was this what you had in mind?

sukvvon avatar Dec 15 '25 11:12 sukvvon