Skip to content

test(vue-query/useMutation): replace 'vi.waitFor' with 'vi.advanceTimersByTimeAsync' in async 'mutateAsync' tests#10966

Merged
sukvvon merged 1 commit into
mainfrom
test/vue-query-usemutation-replace-waitfor
Jun 17, 2026
Merged

test(vue-query/useMutation): replace 'vi.waitFor' with 'vi.advanceTimersByTimeAsync' in async 'mutateAsync' tests#10966
sukvvon merged 1 commit into
mainfrom
test/vue-query-usemutation-replace-waitfor

Conversation

@sukvvon

@sukvvon sukvvon commented Jun 17, 2026

Copy link
Copy Markdown
Member

🎯 Changes

The async block in useMutation.test.ts was the only place still using vi.waitFor to await mutateAsync, even though the suite runs under fake timers and every other test drives time with vi.advanceTimersByTimeAsync. This replaces it so the async tests follow the same explicit fake-timer pattern as the rest of the file.

  • should resolve properly: hold the mutateAsync promise, advance the timer, then await expect(promise).resolves.toBe(result).
  • should throw on error: await Promise.all([expect(mutation.mutateAsync()).rejects.toThrow('Some error'), vi.advanceTimersByTimeAsync(10)]). The rejection assertion is attached before the timer is advanced (the reject fires inside the advanceTimersByTimeAsync call), so the rejection is handled at the moment it occurs — avoiding an unhandled rejection while still satisfying vitest/valid-expect.

No behavior change to the assertions themselves; the subsequent toMatchObject state checks are unchanged.

✅ 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

Release Notes

No user-facing changes. This release includes internal test infrastructure improvements to ensure more reliable test execution.

…ersByTimeAsync' in async 'mutateAsync' tests
@coderabbitai

coderabbitai Bot commented Jun 17, 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: 3e061cc5-ad22-4d1b-a4c8-382ad8edc55c

📥 Commits

Reviewing files that changed from the base of the PR and between 18d4504 and 9087067.

📒 Files selected for processing (1)
  • packages/vue-query/src/__tests__/useMutation.test.ts

📝 Walkthrough

Walkthrough

Two useMutation async tests are refactored to replace vi.waitFor with explicit promise capture and vi.advanceTimersByTimeAsync. The success case stores the mutateAsync promise and awaits it after advancing timers; the error case uses Promise.all to coordinate rejection assertion with timer advancement.

Changes

useMutation async test timer handling

Layer / File(s) Summary
Explicit fake-timer promise assertions
packages/vue-query/src/__tests__/useMutation.test.ts
Success test stores mutateAsync promise, advances fake timers, then asserts resolution. Error test uses Promise.all to assert rejection alongside vi.advanceTimersByTimeAsync(10), replacing vi.waitFor in both cases.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 A promise once waited with waitFor in hand,
Now captured and advanced, just as planned!
Fake timers tick-tock in a neat Promise.all,
No polling required — just one tidy call.
The bunny approves this more precise way! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: replacing vi.waitFor with vi.advanceTimersByTimeAsync in async mutateAsync tests within useMutation.test.ts.
Description check ✅ Passed The description fully completes all required template sections with clear explanations of changes, checked checklist items, and proper release impact marking.
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/vue-query-usemutation-replace-waitfor

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

@nx-cloud

nx-cloud Bot commented Jun 17, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 9087067

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

☁️ Nx Cloud last updated this comment at 2026-06-17 10:42:16 UTC

@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 17, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 17, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 9087067

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

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

@sukvvon sukvvon merged commit 835a299 into main Jun 17, 2026
9 checks passed
@sukvvon sukvvon deleted the test/vue-query-usemutation-replace-waitfor branch June 17, 2026 10:43
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