Skip to content

test(svelte-query/utils): add tests for 'watchChanges' first-run skip, array sources, and cleanup#10979

Merged
sukvvon merged 1 commit into
mainfrom
test/svelte-query-watch-changes
Jun 24, 2026
Merged

test(svelte-query/utils): add tests for 'watchChanges' first-run skip, array sources, and cleanup#10979
sukvvon merged 1 commit into
mainfrom
test/svelte-query-watch-changes

Conversation

@sukvvon

@sukvvon sukvvon commented Jun 24, 2026

Copy link
Copy Markdown
Member

🎯 Changes

Add unit tests for the watchChanges utility in packages/svelte-query/src/utils.svelte.ts, which previously had no direct test coverage.

The added tests cover:

  • Skipping the first run and only invoking the effect on subsequent changes
  • The 'post' flush timing
  • Tracking an array of sources and passing arrays of current/previous values
  • Running the returned cleanup before the next effect run

These bring the 'post' flush branch and the array-sources branch under coverage.

✅ Checklist

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

🚀 Release Impact

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

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for change detection behavior, including flush timing variants and cleanup function execution.

@nx-cloud

nx-cloud Bot commented Jun 24, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 7c54075

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

☁️ Nx Cloud last updated this comment at 2026-06-24 01:45:44 UTC

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d4f4e178-3c69-4810-9a9e-d21ce21b4f52

📥 Commits

Reviewing files that changed from the base of the PR and between b809297 and 7c54075.

📒 Files selected for processing (1)
  • packages/svelte-query/tests/utils.svelte.test.ts

📝 Walkthrough

Walkthrough

Adds a new Vitest test file for the watchChanges utility in packages/svelte-query. The suite covers four behaviors: skipping the initial run with 'pre' flush, running with 'post' flush timing, accepting an array of source getters with current/previous value arrays, and executing the cleanup function before the next effect run.

Changes

watchChanges Utility Tests

Layer / File(s) Summary
watchChanges test suite
packages/svelte-query/tests/utils.svelte.test.ts
Imports flushSync, Vitest helpers, watchChanges, and local ref/withEffectRoot utilities; defines four it cases verifying 'pre' flush skip-on-init, 'post' flush timing, multi-source getter arrays passing current and previous value arrays, and cleanup invocation before subsequent effect runs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐇 A watcher that skips on the very first call,
Then fires on each change, both great and small.
With arrays of sources, old values in tow,
And cleanup that runs before the next flow.
Four tests now confirm what the rabbit knew:
watchChanges works right — hip-hop, it's true! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding tests for 'watchChanges' covering first-run skip, array sources, and cleanup functionality.
Description check ✅ Passed The description includes all required sections (Changes, Checklist, Release Impact), provides clear details about the test coverage added, and properly marks the checklist items and release impact.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/svelte-query-watch-changes

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

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@sukvvon sukvvon self-assigned this Jun 24, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 24, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@10979

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@10979

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@10979

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 7c54075

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 12.13 KB (0%)
react minimal 9.08 KB (0%)

@sukvvon sukvvon merged commit 982c618 into main Jun 24, 2026
9 checks passed
@sukvvon sukvvon deleted the test/svelte-query-watch-changes branch June 24, 2026 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant