Skip to content

test: update assertions deprecated in vitest 4.1#1629

Merged
danielroe merged 1 commit intonuxt:mainfrom
yamachi4416:test-replace-deprecated-assertions
Mar 26, 2026
Merged

test: update assertions deprecated in vitest 4.1#1629
danielroe merged 1 commit intonuxt:mainfrom
yamachi4416:test-replace-deprecated-assertions

Conversation

@yamachi4416
Copy link
Collaborator

@yamachi4416 yamachi4416 commented Mar 23, 2026

🔗 Linked issue

📚 Description

replaced assertions that were deprecated in vitest 4.1:

  • toBe* spy assertions -> toHaveBeen*
  • toThrowError -> toThrow

details of the deprecations in Vitest 4.1 are as follows:

deprecated:

  • toBeCalledTimes -> toHaveBeenCalledTimes
  • toBeCalled -> toHaveBeenCalled
  • toBeCalledWith -> toHaveBeenCalledWith
  • toThrowError -> toThrow
  • toReturnTimes -> toHaveReturnedTimes
  • toReturnWith -> toHaveReturnedWith

removed:

  • nthCalledWith -> toHaveBeenNthCalledWith
  • lastCalledWith -> toHaveBeenLastCalledWith
  • lastReturnedWith -> toHaveLastReturnedWith
  • nthReturnedWith -> toHaveNthReturnedWith

search for repo

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 23, 2026

Open in StackBlitz

npm i https://pkg.pr.new/nuxt/test-utils/@nuxt/test-utils@1629
npm i https://pkg.pr.new/nuxt/test-utils/vitest-environment-nuxt@1629

commit: f882219

@yamachi4416 yamachi4416 marked this pull request as ready for review March 23, 2026 14:29
@yamachi4416 yamachi4416 requested a review from danielroe as a code owner March 23, 2026 14:29
@coderabbitai
Copy link

coderabbitai bot commented Mar 23, 2026

📝 Walkthrough

Walkthrough

This pull request updates test assertion matchers across nine test files in the examples directory to use newer Vitest matcher APIs. The changes replace deprecated or older matcher syntax with their modern equivalents: .toThrowError() to .toThrow(), .toBeCalled() to .toHaveBeenCalled(), .toBeCalledTimes() to .toHaveBeenCalledTimes(), and .toBeCalledWith() to .toHaveBeenCalledWith(). No test logic, control flow, mocking behavior, or test expectations are modified—only the assertion matcher names are updated.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: updating test assertions that were deprecated in Vitest 4.1.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description clearly explains the purpose: updating deprecated Vitest assertions from toBe* to toHaveBeen* and toThrowError to toThrow, with details of what was deprecated in Vitest 4.1.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@OrbisK
Copy link
Member

OrbisK commented Mar 24, 2026

should we update app-vitest-workspace and app-vitest too?

@yamachi4416
Copy link
Collaborator Author

thank you for the review
looking to see if any other deprecated assertions are remaining

@yamachi4416
Copy link
Collaborator Author

thank you
confirmed that there are no other occurrences and updated the PR description

@danielroe danielroe merged commit 1dc7f4c into nuxt:main Mar 26, 2026
8 checks passed
@github-actions github-actions bot mentioned this pull request Mar 26, 2026
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.

3 participants