For your unit tests, @nuxt/test-utils lets you opt-in to a Nuxt environment by adding .nuxt. to the filename of your test:
You can also add a special comment at the top of the file:
Or enable the environment for all Vitest tests in your config: