
"The most consequential change in v4.0.0 is that Nuxt's test environment setup has been moved from setupFiles to the beforeAll hook. This change fixes a pair of long-standing issues in the repository, both filed by users reporting that module-level mocks were being silently ignored."
"With setup deferred to beforeAll, mocks are registered before Nuxt starts, making mock behaviour consistent and predictable across the test suite. This does carry a migration cost, as code that calls Nuxt composables at the top level of a describe block will now throw [nuxt] instance unavailable."
"The second notable improvement is to mockNuxtImport, which now passes the original implementation to the factory function. This makes partial mocking substantially cleaner, allowing tests to wrap or extend the real implementation and then narrow behaviour per-test."
Nuxt Test Utils version 4.0.0, released on February 7, 2026, is built around Vitest v4. The test environment setup has shifted to the beforeAll hook, resolving issues with module-level mocks. This change ensures that mocks are registered before Nuxt starts, enhancing consistency. However, it requires migration for top-level calls to Nuxt composables. Additionally, mockNuxtImport now allows for cleaner partial mocking by passing the original implementation to the factory function. The update also includes targeted fixes to the registerEndpoint utility.
Read at InfoQ
Unable to calculate read time
Collection
[
|
...
]