Skip to content

Conversation

sukvvon
Copy link
Contributor

@sukvvon sukvvon commented Sep 8, 2025

Summary by CodeRabbit

  • Tests
    • Tightened assertions to verify exact call order and arguments for mutation callbacks, improving clarity and reliability while keeping call counts unchanged. No runtime behavior impact.
  • Style
    • Applied object property shorthand in a test example for cleaner syntax with no semantic changes.
  • Chores
    • No user-facing changes or API modifications; updates are limited to tests and minor style improvements.

…toHaveBeenNthCalledWith' and apply shorthand property syntax in FailureExample
Copy link

coderabbitai bot commented Sep 8, 2025

Walkthrough

The PR updates a Svelte test component to use object property shorthand in a createMutation call and adjusts test assertions to use nth-call checks for mock callbacks while keeping total call counts the same. No public APIs or exports are changed.

Changes

Cohort / File(s) Summary of Changes
Test component cleanup
packages/svelte-query/tests/createMutation/FailureExample.svelte
Replaced { mutationFn: mutationFn } with { mutationFn } in createMutation options; no behavioral changes.
Test assertions tightening
packages/svelte-query/tests/createMutation/createMutation.test.ts
Switched from generic toHaveBeenCalledWith to toHaveBeenNthCalledWith(1/2/3, ...) for onSuccessMock and onSettledMock; preserved expected call counts (3).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch my nose at tidy lines,
Shorthand hops through Sveltey pines.
Tests count calls—one, two, three—just so,
Each nth nibble in a row.
Carrots stacked, assertions neat—
A rabbit’s work is clean and sweet. 🥕✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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.

Copy link

nx-cloud bot commented Sep 8, 2025

View your CI Pipeline Execution ↗ for commit d049df2

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

☁️ Nx Cloud last updated this comment at 2025-09-08 12:54:56 UTC

Copy link

pkg-pr-new bot commented Sep 8, 2025

More templates

@tanstack/angular-query-devtools-experimental

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

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: d049df2

Copy link

codecov bot commented Sep 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.20%. Comparing base (af50368) to head (d049df2).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #9630       +/-   ##
===========================================
+ Coverage   45.50%   89.20%   +43.69%     
===========================================
  Files         209       18      -191     
  Lines        8377      176     -8201     
  Branches     1904       31     -1873     
===========================================
- Hits         3812      157     -3655     
+ Misses       4118       18     -4100     
+ Partials      447        1      -446     
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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/svelte-query/tests/createMutation/createMutation.test.ts (2)

51-53: DRY up repeated nth-call assertions

Minor style: a loop keeps the expectations compact while preserving intent.

-    expect(onSuccessMock).toHaveBeenNthCalledWith(1, 1)
-    expect(onSuccessMock).toHaveBeenNthCalledWith(2, 2)
-    expect(onSuccessMock).toHaveBeenNthCalledWith(3, 3)
+    for (const n of [1, 2, 3]) {
+      expect(onSuccessMock).toHaveBeenNthCalledWith(n, n)
+    }
@@
-    expect(onSettledMock).toHaveBeenNthCalledWith(1, 1)
-    expect(onSettledMock).toHaveBeenNthCalledWith(2, 2)
-    expect(onSettledMock).toHaveBeenNthCalledWith(3, 3)
+    for (const n of [1, 2, 3]) {
+      expect(onSettledMock).toHaveBeenNthCalledWith(n, n)
+    }

Also applies to: 56-58


51-53: Assert each onSuccess runs before its corresponding onSettled

Add immediately after the existing expectations (lines 56–58):

+    // Ensure each onSuccess occurs before its corresponding onSettled
+    const successOrder = onSuccessMock.mock.invocationCallOrder
+    const settledOrder = onSettledMock.mock.invocationCallOrder
+    for (let i = 0; i < 3; i++) {
+      expect(successOrder[i]).toBeLessThan(settledOrder[i])
+    }

Vitest exposes mock.invocationCallOrder and also provides toHaveBeenCalledBefore/toHaveBeenCalledAfter matchers—use whichever yields clearer intent.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f023881 and 3f73f82.

📒 Files selected for processing (2)
  • packages/svelte-query/tests/createMutation/FailureExample.svelte (1 hunks)
  • packages/svelte-query/tests/createMutation/createMutation.test.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Preview
  • GitHub Check: Test
🔇 Additional comments (1)
packages/svelte-query/tests/createMutation/FailureExample.svelte (1)

15-15: LGTM: idiomatic object property shorthand

No behavior change; this keeps the options concise and clear.

@TkDodo TkDodo merged commit ccedf33 into TanStack:main Sep 8, 2025
8 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