chore(deps): update devdependency @nuxt/test-utils to v4
This PR contains the following updates:
| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [@nuxt/test-utils](https://redirect.github.com/nuxt/test-utils) | [`^3.19.2` → `^4.0.0`](https://renovatebot.com/diffs/npm/@nuxt%2ftest-utils/3.19.2/4.0.0) |  |  |
---
### Release Notes
<details>
<summary>nuxt/test-utils (@​nuxt/test-utils)</summary>
### [`v4.0.0`](https://redirect.github.com/nuxt/test-utils/releases/tag/v4.0.0)
[Compare Source](https://redirect.github.com/nuxt/test-utils/compare/v3.23.0...v4.0.0)
> 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](https://redirect.github.com/nuxt/test-utils/pull/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](https://redirect.github.com/nuxt/test-utils/issues/750), [#​836](https://redirect.github.com/nuxt/test-utils/issues/836), [#​1496](https://redirect.github.com/nuxt/test-utils/issues/1496)).
On top of that, `mockNuxtImport` now passes the original implementation to the factory function ([#​1552](https://redirect.github.com/nuxt/test-utils/pull/1552)), making partial mocking much more natural:
```ts
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](https://redirect.github.com/nuxt/test-utils/pull/1560)), and endpoints registered in setup files are no longer lost when modules reset ([#​1549](https://redirect.github.com/nuxt/test-utils/pull/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](https://vite.dev/guide/api-environment-runtimes.html#modulerunner) 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](#describe-blocks-run-during-collection).
##### Update your dependencies
Update `vitest` and its companion packages together:
```diff
{
"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`.
```ts
// 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`.
```ts
// 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](https://vitest.dev/guide/migration#vitest-4).
#### 👉 Changelog
[compare changes](https://redirect.github.com/nuxt/test-utils/compare/v3.23.0...v4.0.0)
##### 🚀 Enhancements
- **deps:** ⚠️ Upgrade to vitest v4 ([#​1481](https://redirect.github.com/nuxt/test-utils/pull/1481))
- **deps:** ⚠️ Drop official support for older versions of test runners + dom environments ([31fdc262a](https://redirect.github.com/nuxt/test-utils/commit/31fdc262a))
- **runtime-utils:** Pass original to `mockNuxtImport` factory ([#​1552](https://redirect.github.com/nuxt/test-utils/pull/1552))
- **runtime:** ⚠️ Change nuxt start timing to `beforeAll` hook ([#​1516](https://redirect.github.com/nuxt/test-utils/pull/1516))
- **e2e:** Support setup and teardown timeouts in setupBun ([#​1578](https://redirect.github.com/nuxt/test-utils/pull/1578))
##### 🩹 Fixes
- **runtime:** Handle optional chaining vueWrapper plugin installed check ([#​1547](https://redirect.github.com/nuxt/test-utils/pull/1547))
- **runtime-utils:** Keep endpoints from registerEndpoint in setup file ([#​1549](https://redirect.github.com/nuxt/test-utils/pull/1549))
- **runtime-utils:** Support `registerEndpoint` with query params ([#​1560](https://redirect.github.com/nuxt/test-utils/pull/1560))
- **runtime-utils:** Avoid local variable in mockNuxtImport macro ([#​1564](https://redirect.github.com/nuxt/test-utils/pull/1564))
- **runtime-utils:** Add missing `nextTick` import ([#​1563](https://redirect.github.com/nuxt/test-utils/pull/1563))
- Pin h3-next to patch ([1ff3bbb91](https://redirect.github.com/nuxt/test-utils/commit/1ff3bbb91))
- **playwright:** Bump windows timeout ([63e39b7c9](https://redirect.github.com/nuxt/test-utils/commit/63e39b7c9))
- **config:** Respect include options in non nuxt environment simple setup ([#​1570](https://redirect.github.com/nuxt/test-utils/pull/1570))
##### 💅 Refactors
- **module:** Use `@nuxt/devtools-kit` for devtools hooks ([426e0b537](https://redirect.github.com/nuxt/test-utils/commit/426e0b537))
- **runtime:** Remove unnecessary querySelector ([#​1577](https://redirect.github.com/nuxt/test-utils/pull/1577))
##### 📖 Documentation
- Add nuxt.care health badge ([1499a48de](https://redirect.github.com/nuxt/test-utils/commit/1499a48de))
##### 🏡 Chore
- Allow changelog update util to return major bump ([9e86cadab](https://redirect.github.com/nuxt/test-utils/commit/9e86cadab))
- Make `app-vitest` follow advised setup guidelines ([#​1542](https://redirect.github.com/nuxt/test-utils/pull/1542))
- Update lockfile ([6d798b5e1](https://redirect.github.com/nuxt/test-utils/commit/6d798b5e1))
- **config:** Migrate Renovate config ([#​1568](https://redirect.github.com/nuxt/test-utils/pull/1568))
- Add test utils setup to `.nuxtrc` ([b4021dee4](https://redirect.github.com/nuxt/test-utils/commit/b4021dee4))
##### ✅ Tests
- Avoid running root test script twice ([44f6bd396](https://redirect.github.com/nuxt/test-utils/commit/44f6bd396))
##### ⚠️ Breaking Changes
- **deps:** ⚠️ Upgrade to vitest v4 ([#​1481](https://redirect.github.com/nuxt/test-utils/pull/1481))
- **deps:** ⚠️ Drop official support for older versions of test runners + dom environments ([31fdc262a](https://redirect.github.com/nuxt/test-utils/commit/31fdc262a))
- **runtime:** ⚠️ Change nuxt start timing to `beforeAll` hook ([#​1516](https://redirect.github.com/nuxt/test-utils/pull/1516))
##### ❤️ Contributors
- Yoshihiro Yamaguchi ([@​yamachi4416](https://redirect.github.com/yamachi4416))
- Daniel Roe ([@​danielroe](https://redirect.github.com/danielroe))
- Adam DeHaven ([@​adamdehaven](https://redirect.github.com/adamdehaven))
### [`v3.23.0`](https://redirect.github.com/nuxt/test-utils/releases/tag/v3.23.0)
[Compare Source](https://redirect.github.com/nuxt/test-utils/compare/v3.22.0...v3.23.0)
> 3.23.0 is the next minor release.
#### 👉 Changelog
[compare changes](https://redirect.github.com/nuxt/test-utils/compare/v3.22.0...v3.23.0)
##### 🚀 Enhancements
- **runtime-utils:** Support h3 v2 ([#​1515](https://redirect.github.com/nuxt/test-utils/pull/1515))
- **module:** Add install wizard when freshly installed ([#​1538](https://redirect.github.com/nuxt/test-utils/pull/1538))
##### 🩹 Fixes
- **e2e:** Ensure `$fetch` is not typed as `any` ([1f4754ea9](https://redirect.github.com/nuxt/test-utils/commit/1f4754ea9))
##### 🏡 Chore
- Remove leftover `console.log` ([aef693340](https://redirect.github.com/nuxt/test-utils/commit/aef693340))
##### ✅ Tests
- Add cleanup to resolve-config tests ([#​1537](https://redirect.github.com/nuxt/test-utils/pull/1537))
##### 🤖 CI
- Prepare build environment in autofix workflow ([2c0864ed6](https://redirect.github.com/nuxt/test-utils/commit/2c0864ed6))
##### ❤️ Contributors
- Daniel Roe ([@​danielroe](https://redirect.github.com/danielroe))
- yamachi4416 ([@​yamachi4416](https://redirect.github.com/yamachi4416))
### [`v3.22.0`](https://redirect.github.com/nuxt/test-utils/releases/tag/v3.22.0)
[Compare Source](https://redirect.github.com/nuxt/test-utils/compare/v3.21.0...v3.22.0)
> 3.22.0 is the next minor release.
#### 👉 Changelog
[compare changes](https://redirect.github.com/nuxt/test-utils/compare/v3.21.0...v3.22.0)
##### 🚀 Enhancements
- **runtime-utils:** Unify logic of mount + render helpers ([#​1522](https://redirect.github.com/nuxt/test-utils/pull/1522))
- **module:** Run `vitest` in separate process ([#​1524](https://redirect.github.com/nuxt/test-utils/pull/1524))
- **runtime-utils:** Allow skipping initial route change ([fd77ec066](https://redirect.github.com/nuxt/test-utils/commit/fd77ec066))
- **runtime:** Skip route sync emulation when `NuxtPage` exists ([#​1530](https://redirect.github.com/nuxt/test-utils/pull/1530))
##### 🔥 Performance
- **module:** Skip nuxt-root stub plugin when building ([#​1512](https://redirect.github.com/nuxt/test-utils/pull/1512))
##### 🩹 Fixes
- **runtime-utils:** Reject promise on error render + mount helpers ([#​1503](https://redirect.github.com/nuxt/test-utils/pull/1503))
- **runtime-utils:** Support new `.sync` method for syncing route ([1148c3cf1](https://redirect.github.com/nuxt/test-utils/commit/1148c3cf1))
- **e2e:** Always override global env options with inline options ([c8f881b3d](https://redirect.github.com/nuxt/test-utils/commit/c8f881b3d))
- **runtime-utils:** Avoid missing render warn on reject render + suspend helpers ([#​1520](https://redirect.github.com/nuxt/test-utils/pull/1520))
- **e2e:** Use `server.deps` rather than `deps` ([2b3c86921](https://redirect.github.com/nuxt/test-utils/commit/2b3c86921))
- **config:** Also call `sync()` in initial setup ([ec555192c](https://redirect.github.com/nuxt/test-utils/commit/ec555192c))
- **module:** Use `devtools:before` hook instead of direct config check ([#​1532](https://redirect.github.com/nuxt/test-utils/pull/1532))
- **config:** Do not override vitest root with nuxt `rootDir` ([#​1531](https://redirect.github.com/nuxt/test-utils/pull/1531))
##### 💅 Refactors
- **runtime-utils:** Do not export `addCleanup` ([86b4998bb](https://redirect.github.com/nuxt/test-utils/commit/86b4998bb))
- **module:** Extract nuxt environment options plugin ([5ada22a9f](https://redirect.github.com/nuxt/test-utils/commit/5ada22a9f))
##### 📖 Documentation
- Fix link to module authors testing guide ([#​1511](https://redirect.github.com/nuxt/test-utils/pull/1511))
##### 🏡 Chore
- Use `nuxt` cli command in preference to `nuxi` ([838ed8b6a](https://redirect.github.com/nuxt/test-utils/commit/838ed8b6a))
- Add `@vitest/ui` to example ([ffaccd8a1](https://redirect.github.com/nuxt/test-utils/commit/ffaccd8a1))
- Fix some example `package.json` names ([417102718](https://redirect.github.com/nuxt/test-utils/commit/417102718))
- Skip bun test ([c19a659d3](https://redirect.github.com/nuxt/test-utils/commit/c19a659d3))
- Ignore root interfaces ([9739057ae](https://redirect.github.com/nuxt/test-utils/commit/9739057ae))
##### ✅ Tests
- Use local kit version for module ([79f1e14d5](https://redirect.github.com/nuxt/test-utils/commit/79f1e14d5))
- Add `defaultLocale` in i18n test ([059988fc3](https://redirect.github.com/nuxt/test-utils/commit/059988fc3))
- Avoid definePageMeta compiler-hint warning ([#​1523](https://redirect.github.com/nuxt/test-utils/pull/1523))
##### 🤖 CI
- Run `knip` on pull requests ([a94098671](https://redirect.github.com/nuxt/test-utils/commit/a94098671))
##### ❤️ Contributors
- Daniel Roe ([@​danielroe](https://redirect.github.com/danielroe))
- yamachi4416 ([@​yamachi4416](https://redirect.github.com/yamachi4416))
- Maurice Putz ([@​Shooteger](https://redirect.github.com/Shooteger))
### [`v3.21.0`](https://redirect.github.com/nuxt/test-utils/releases/tag/v3.21.0)
[Compare Source](https://redirect.github.com/nuxt/test-utils/compare/v3.20.1...v3.21.0)
> 3.21.0 is the next minor release.
#### 👉 Changelog
[compare changes](https://redirect.github.com/nuxt/test-utils/compare/v3.20.1...v3.21.0)
##### 🚀 Enhancements
- **runtime-utils:** Support rerender behavior in renderSuspended ([#​1466](https://redirect.github.com/nuxt/test-utils/pull/1466))
- **runtime-utils:** Support `once` option in `registerEndpoint` ([#​1475](https://redirect.github.com/nuxt/test-utils/pull/1475))
- **runtime-utils:** Support css modules in mount + render helpers ([#​1464](https://redirect.github.com/nuxt/test-utils/pull/1464))
- **runtime-utils:** Pass app context across in mount + render helpers ([#​1477](https://redirect.github.com/nuxt/test-utils/pull/1477))
- **runtime-utils:** Support mocked target arguments in mockNuxtImport ([#​1492](https://redirect.github.com/nuxt/test-utils/pull/1492))
##### 🩹 Fixes
- **runtime:** Remove redefinition of `$fetch.create` ([#​1471](https://redirect.github.com/nuxt/test-utils/pull/1471))
- **runtime-utils:** Pass non-enumerable `globalProperties` in mount + render helpers ([#​1476](https://redirect.github.com/nuxt/test-utils/pull/1476))
- **module:** Include vitest config in node project ([#​1497](https://redirect.github.com/nuxt/test-utils/pull/1497))
- **runtime-utils:** Improve mount + render helpers ([#​1483](https://redirect.github.com/nuxt/test-utils/pull/1483))
- Revert to `@nuxt/kit` v3 for bridge support ([#​1498](https://redirect.github.com/nuxt/test-utils/pull/1498))
##### 🏡 Chore
- Move built dep configuration -> workspace file ([d936cb465](https://redirect.github.com/nuxt/test-utils/commit/d936cb465))
- Update pnpm to 10.21 and enable trust policy ([ed6ff050d](https://redirect.github.com/nuxt/test-utils/commit/ed6ff050d))
- Revert pnpm trust policy and restore provenance action ([b034f0a5e](https://redirect.github.com/nuxt/test-utils/commit/b034f0a5e))
- Remove spurious `globby` dependency ([eba19d16b](https://redirect.github.com/nuxt/test-utils/commit/eba19d16b))
- Remove export ([2a88683bd](https://redirect.github.com/nuxt/test-utils/commit/2a88683bd))
- Remove `@nuxt/kit` from peer dependencies ([b80ca5ea8](https://redirect.github.com/nuxt/test-utils/commit/b80ca5ea8))
- Add back `@nuxt/kit` as peer dep ([5c126e1af](https://redirect.github.com/nuxt/test-utils/commit/5c126e1af))
- Bump vite-node to v5 ([3322919c2](https://redirect.github.com/nuxt/test-utils/commit/3322919c2))
##### 🤖 CI
- Rebuild better-sqlite3 on windows ([9fdaf3824](https://redirect.github.com/nuxt/test-utils/commit/9fdaf3824))
##### ❤️ Contributors
- Daniel Roe ([@​danielroe](https://redirect.github.com/danielroe))
- yamachi4416 ([@​yamachi4416](https://redirect.github.com/yamachi4416))
- Ryota Watanabe ([@​wattanx](https://redirect.github.com/wattanx))
### [`v3.20.1`](https://redirect.github.com/nuxt/test-utils/compare/v3.19.2...v3.20.1)
[Compare Source](https://redirect.github.com/nuxt/test-utils/compare/v3.19.2...v3.20.1)
</details>
---
### Configuration
📅 **Schedule**: Branch creation - "on Monday" (UTC), Automerge - At any time (no schedule defined).
🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.
♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 **Ignore**: Close this PR and you won't be reminded about this update again.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box
---
This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/nuxt-modules/leaflet).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi45NS4yIiwidXBkYXRlZEluVmVyIjoiNDIuOTUuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
合并状态:未合并 2 条评论