Skip to content

test(vue-query/useMutationState): split 'useMutationState' tests into separate file from 'useIsMutating.test.ts'#10236

Open
sukvvon wants to merge 1 commit intoTanStack:mainfrom
sukvvon:test/vue-query-split-useMutationState-tests
Open

test(vue-query/useMutationState): split 'useMutationState' tests into separate file from 'useIsMutating.test.ts'#10236
sukvvon wants to merge 1 commit intoTanStack:mainfrom
sukvvon:test/vue-query-split-useMutationState-tests

Conversation

@sukvvon
Copy link
Contributor

@sukvvon sukvvon commented Mar 5, 2026

🎯 Changes

  • Split useMutationState tests from useIsMutating.test.ts into a dedicated useMutationState.test.ts file, aligning with the test file structure used in other packages (react-query, preact-query, solid-query, svelte-query).

✅ 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
    • Added comprehensive test coverage for mutation state behavior and reactivity.
    • Refactored test organization for improved focus and maintainability.

@changeset-bot
Copy link

changeset-bot bot commented Mar 5, 2026

⚠️ No Changeset found

Latest commit: eeb3b57

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 5, 2026

📝 Walkthrough

Walkthrough

The changes reorganize test coverage for Vue Query's mutation hooks by removing useMutationState tests from the useIsMutating test file and establishing a dedicated test file for useMutationState with comprehensive behavioral scenarios.

Changes

Cohort / File(s) Summary
Test Reorganization
packages/vue-query/src/__tests__/useIsMutating.test.ts
Removed useMutationState and useQueryClient-related tests and imports; retained only useIsMutating-focused test cases, reducing file by 73 net lines.
New Test Suite
packages/vue-query/src/__tests__/useMutationState.test.ts
Added comprehensive test file for useMutationState covering variable retrieval post-mutation, reactive selector patterns, and async behavior with mocked useQueryClient and fake timers.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Tests hop and reorganize with glee,
Mutations now have their own decree,
useMutationState finds its home,
While useIsMutating stands alone,
State management tests, so clean and free! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: splitting useMutationState tests from useIsMutating.test.ts into a separate file, which is clearly supported by the raw summary and changes made.
Description check ✅ Passed The description covers the main change clearly, includes the rationale (alignment with other packages), has completed the required checklist items, and correctly identifies this as a dev-only change with no release impact.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ 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.

@nx-cloud
Copy link

nx-cloud bot commented Mar 5, 2026

View your CI Pipeline Execution ↗ for commit eeb3b57

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

☁️ Nx Cloud last updated this comment at 2026-03-05 04:54:01 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 5, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: b9c12db

Copy link
Contributor

@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.

🧹 Nitpick comments (1)
packages/vue-query/src/__tests__/useMutationState.test.ts (1)

19-54: Consider more descriptive test names.

The test names "mutate 1" and "mutate 2" don't convey what scenario each test covers. Consider renaming to better describe the differences:

  • Test 1 uses filters and select options
  • Test 2 uses no options (default behavior)
✏️ Suggested naming improvement
-  it('should return variables after calling mutate 1', () => {
+  it('should return variables with filters and select option', () => {
-  it('should return variables after calling mutate 2', () => {
+  it('should return variables with default options', () => {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/vue-query/src/__tests__/useMutationState.test.ts` around lines 19 -
54, The test names are not descriptive; rename the two it() descriptions to
reflect their scenarios: change "should return variables after calling mutate 1"
to something like "should return variables when using filters and select
options" (covers useMutation with mutationKey/variables, then useMutationState
with filters and select) and change "should return variables after calling
mutate 2" to something like "should return variables by default when no options
provided" (covers clearing the queryClient, useMutation, mutate, then
useMutationState() with default behavior); update only the it() string literals
surrounding the tests that call useMutation, mutate, and useMutationState so
they clearly describe the differences.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/vue-query/src/__tests__/useMutationState.test.ts`:
- Around line 19-54: The test names are not descriptive; rename the two it()
descriptions to reflect their scenarios: change "should return variables after
calling mutate 1" to something like "should return variables when using filters
and select options" (covers useMutation with mutationKey/variables, then
useMutationState with filters and select) and change "should return variables
after calling mutate 2" to something like "should return variables by default
when no options provided" (covers clearing the queryClient, useMutation, mutate,
then useMutationState() with default behavior); update only the it() string
literals surrounding the tests that call useMutation, mutate, and
useMutationState so they clearly describe the differences.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a48a01fd-262d-49d9-a977-a9ae7a18c6b7

📥 Commits

Reviewing files that changed from the base of the PR and between fe25edc and eeb3b57.

📒 Files selected for processing (2)
  • packages/vue-query/src/__tests__/useIsMutating.test.ts
  • packages/vue-query/src/__tests__/useMutationState.test.ts

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.

1 participant