Skip to content

chore: Update dependency @nuxt/test-utils to v4#83

Closed
renovate[bot] wants to merge 1 commit intomainfrom
renovate/nuxt-test-utils-4.x
Closed

chore: Update dependency @nuxt/test-utils to v4#83
renovate[bot] wants to merge 1 commit intomainfrom
renovate/nuxt-test-utils-4.x

Conversation

@renovate
Copy link
Contributor

@renovate renovate bot commented Feb 9, 2026

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
@nuxt/test-utils ^3.23.0^4.0.0 age adoption passing confidence

Release Notes

nuxt/test-utils (@​nuxt/test-utils)

v4.0.0

Compare Source

4.0.0 is the next major release.

👀 Highlights

We're releasing Nuxt Test Utils v4, with support for Vitest v4. 🚀

Better mocking support

The biggest improvement in this release is how mocking works. Nuxt initialization has been moved from setupFiles to the beforeAll hook (#​1516), which means vi.mock and mockNuxtImport calls now take effect before Nuxt starts. This fixes a long-standing issue where mocks for composables used in middleware or plugins wouldn't apply reliably (#​750, #​836, #​1496).

On top of that, mockNuxtImport now passes the original implementation to the factory function (#​1552), making partial mocking much more natural:

mockNuxtImport('useRoute', original => vi.fn(original))

it('my test', async () => {
  vi.mocked(useRoute).mockImplementation(
    (...args) => ({ ...vi.mocked(useRoute).getMockImplementation()!(...args), path: '/mocked' }),
  )

  const wrapper = await mountSuspended(MyComponent)
  expect(wrapper.find('#path').text()).toBe('/mocked')
})
registerEndpoint improvements

registerEndpoint now works correctly with query parameters in URLs (#​1560), and endpoints registered in setup files are no longer lost when modules reset (#​1549).

🚧 Migration

@nuxt/test-utils v4 contains a few breaking changes, almost all related to requiring at least vitest v4 as a peer dependency (if you are using vitest). It replaces vite-node with Vite's native Module Runner and simplifies pool configuration.

This will mean improvements for test performance and mocking, but does require some changes to your test code.

[!TIP]
Most of the changes below are straightforward. The biggest thing to watch out for is code that runs at the top level of a describe block — see below.

Update your dependencies

Update vitest and its companion packages together:

{
  "devDependencies": {
-   "@​nuxt/test-utils": "^3.x",
-   "vitest": "^3.x",
-   "@​vitest/coverage-v8": "^3.x"
+   "@​nuxt/test-utils": "^4.0",
+   "vitest": "^4.0",
+   "@​vitest/coverage-v8": "^4.0"
  }
}
Peer dependencies

We've tightened peer dependency ranges. You may need to update some of these:

Dependency v3 v4
vitest ^3.2.0 ^4.0.2
happy-dom * >=20.0.11
jsdom * >=27.4.0
@jest/globals ^29.5.0 || >=30.0.0 >=30.0.0
@cucumber/cucumber ^10.3.1 || >=11.0.0 >=11.0.0
@testing-library/vue ^7.0.0 || ^8.0.1 ^8.0.1
Later environment setup

This is the change that might require most change in your tests. Because we've moved the nuxt environment setup into beforeAll, this means composables called at the top level of a describe block will fail with [nuxt] instance unavailable.

// Before (worked in vitest v3)
describe('my test', () => {
  const router = useRouter() // ran lazily, after environment setup
  // ...
})

// After (vitest v4)
describe('my test', () => {
  let router: ReturnType<typeof useRouter>

  beforeAll(() => {
    router = useRouter() // runs after environment setup
  })
  // ...
})

This applies to useRouter(), useNuxtApp(), useRoute(), and any other Nuxt composable or auto-import.

[!TIP]
If you only need the value within individual tests, beforeEach or directly within the test works too.

Stricter mock exports

If you use vi.mock with a factory function, accessing an export that the factory doesn't return will now throw an error instead of silently returning undefined.

// Before: accessing `bar` would silently return undefined
vi.mock('./module', () => ({ foo: 'mocked' }))

// After: accessing `bar` throws
// Fix: use importOriginal to include all exports
vi.mock('./module', async (importOriginal) => ({
  ...await importOriginal(),
  foo: 'mocked',
}))

[!NOTE]
If you're mocking a virtual module (like #build/nuxt.config.mjs) where importOriginal can't resolve the real module, you might need to explicitly list all accessed exports in your mock factory.

Other changes

For the full list, see the vitest v4 migration guide.

👉 Changelog

compare changes

🚀 Enhancements
  • deps: ⚠️ Upgrade to vitest v4 (#​1481)
  • deps: ⚠️ Drop official support for older versions of test runners + dom environments (31fdc262a)
  • runtime-utils: Pass original to mockNuxtImport factory (#​1552)
  • runtime: ⚠️ Change nuxt start timing to beforeAll hook (#​1516)
  • e2e: Support setup and teardown timeouts in setupBun (#​1578)
🩹 Fixes
  • runtime: Handle optional chaining vueWrapper plugin installed check (#​1547)
  • runtime-utils: Keep endpoints from registerEndpoint in setup file (#​1549)
  • runtime-utils: Support registerEndpoint with query params (#​1560)
  • runtime-utils: Avoid local variable in mockNuxtImport macro (#​1564)
  • runtime-utils: Add missing nextTick import (#​1563)
  • Pin h3-next to patch (1ff3bbb91)
  • playwright: Bump windows timeout (63e39b7c9)
  • config: Respect include options in non nuxt environment simple setup (#​1570)
💅 Refactors
  • module: Use @nuxt/devtools-kit for devtools hooks (426e0b537)
  • runtime: Remove unnecessary querySelector (#​1577)
📖 Documentation
🏡 Chore
  • Allow changelog update util to return major bump (9e86cadab)
  • Make app-vitest follow advised setup guidelines (#​1542)
  • Update lockfile (6d798b5e1)
  • config: Migrate Renovate config (#​1568)
  • Add test utils setup to .nuxtrc (b4021dee4)
✅ Tests
  • Avoid running root test script twice (44f6bd396)
⚠️ Breaking Changes
  • deps: ⚠️ Upgrade to vitest v4 (#​1481)
  • deps: ⚠️ Drop official support for older versions of test runners + dom environments (31fdc262a)
  • runtime: ⚠️ Change nuxt start timing to beforeAll hook (#​1516)
❤️ Contributors

Configuration

📅 Schedule: Branch creation - Between 12:00 AM and 03:59 AM, only on Monday ( * 0-3 * * 1 ) (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Enabled.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate
Copy link
Contributor Author

renovate bot commented Feb 9, 2026

⚠️ Artifact update problem

Renovate failed to update an artifact related to this branch. You probably do not want to merge this PR as-is.

♻ Renovate will retry this branch, including artifacts, only when one of the following happens:

  • any of the package files in this branch needs updating, or
  • the branch becomes conflicted, or
  • you click the rebase/retry checkbox if found above, or
  • you rename this PR's title to start with "rebase!" to trigger it manually

The artifact failure details are included below:

File name: package-lock.json
npm warn Unknown env config "store". This will stop working in the next major version of npm.
npm warn Unknown project config "shamefully-hoist". This will stop working in the next major version of npm.
npm warn Unknown project config "strict-peer-dependencies". This will stop working in the next major version of npm.
npm warn ERESOLVE overriding peer dependency
npm warn While resolving: @eslint/compat@1.2.5
npm warn Found: eslint@10.0.0
npm warn node_modules/eslint
npm warn   dev eslint@"^10.0.0" from the root project
npm warn   10 more (@eslint-community/eslint-utils, @nuxt/eslint-config, ...)
npm warn
npm warn Could not resolve dependency:
npm warn peerOptional eslint@"^9.10.0" from @eslint/compat@1.2.5
npm warn node_modules/@eslint/compat
npm warn   @eslint/compat@"^1.2.5" from eslint-config-flat-gitignore@2.1.0
npm warn   node_modules/eslint-config-flat-gitignore
npm warn
npm warn Conflicting peer dependency: eslint@9.39.2
npm warn node_modules/eslint
npm warn   peerOptional eslint@"^9.10.0" from @eslint/compat@1.2.5
npm warn   node_modules/@eslint/compat
npm warn     @eslint/compat@"^1.2.5" from eslint-config-flat-gitignore@2.1.0
npm warn     node_modules/eslint-config-flat-gitignore
npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: @nuxt/test-utils@4.0.0
npm error Found: vitest@3.2.4
npm error node_modules/vitest
npm error   dev vitest@"^3.2.4" from the root project
npm error
npm error Could not resolve dependency:
npm error peerOptional vitest@"^4.0.2" from @nuxt/test-utils@4.0.0
npm error node_modules/@nuxt/test-utils
npm error   dev @nuxt/test-utils@"^4.0.0" from the root project
npm error   @nuxt/test-utils@">=3.13.1" from vitest-environment-nuxt@1.0.1
npm error   node_modules/vitest-environment-nuxt
npm error     vitest-environment-nuxt@"^1.0.1" from @nuxt/test-utils@4.0.0
npm error
npm error Conflicting peer dependency: vitest@4.0.18
npm error node_modules/vitest
npm error   peerOptional vitest@"^4.0.2" from @nuxt/test-utils@4.0.0
npm error   node_modules/@nuxt/test-utils
npm error     dev @nuxt/test-utils@"^4.0.0" from the root project
npm error     @nuxt/test-utils@">=3.13.1" from vitest-environment-nuxt@1.0.1
npm error     node_modules/vitest-environment-nuxt
npm error       vitest-environment-nuxt@"^1.0.1" from @nuxt/test-utils@4.0.0
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /runner/cache/others/npm/_logs/2026-02-16T09_52_38_546Z-eresolve-report.txt
npm error A complete log of this run can be found in: /runner/cache/others/npm/_logs/2026-02-16T09_52_38_546Z-debug-0.log

@renovate renovate bot force-pushed the renovate/nuxt-test-utils-4.x branch from b1b157f to 367bffe Compare February 9, 2026 05:57
@renovate renovate bot force-pushed the renovate/nuxt-test-utils-4.x branch 2 times, most recently from aff10a6 to 5468bf7 Compare February 16, 2026 07:59
@renovate renovate bot force-pushed the renovate/nuxt-test-utils-4.x branch from 5468bf7 to fa4d113 Compare February 16, 2026 09:52
@freb97 freb97 closed this Feb 16, 2026
@renovate
Copy link
Contributor Author

renovate bot commented Feb 16, 2026

Renovate Ignore Notification

Because you closed this PR without merging, Renovate will ignore this update. You will not get PRs for any future 4.x releases. But if you manually upgrade to 4.x then Renovate will re-enable minor and patch updates automatically.

If you accidentally closed this PR, or if you changed your mind: rename this PR to get a fresh replacement PR.

@renovate renovate bot deleted the renovate/nuxt-test-utils-4.x branch February 16, 2026 09:59
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