Environment
- Operating System: Linux
- Node Version: v20.16.0
- Nuxt Version: 3.17.2
- CLI Version: 3.25.0
- Nitro Version: 2.11.11
- Package Manager: npm@10.8.1
- Builder: -
- User Config: modules, devtools, compatibilityDate
- Runtime Modules: @nuxt/test-utils/module@3.18.0
- Build Modules: -
Reproduction
Github repo: https://github.com/wuiyang/nuxt-layer-test-bug
Stackblitz: https://stackblitz.com/~/github.com/wuiyang/nuxt-layer-test-bug
Describe the bug
When project root is using Nuxt 4 version (via config future.compatibilityVersion = 4), nuxt test utils would not work on layers within same project.

The unit test would run without console error log, but the test report would show there is an error:
TypeError: Cannot read properties of undefined (reading 'vueApp')
When project root is not using Nuxt 4 version, the nuxt test utils would work as expected.
See reproduction repo:
Additional context
No response
Logs
abc@efac4cbfa0a5:/..../nuxt-layer-test-bug$ npx vitest run --coverage
Vitest "environmentMatchGlobs" is deprecated. Use "workspace" to define different configurations instead.
HTML Report is generated
You can run npx vite preview --outDir ../test-reports/unit-test to see the test results.
Environment
Reproduction
Github repo: https://github.com/wuiyang/nuxt-layer-test-bug
Stackblitz: https://stackblitz.com/~/github.com/wuiyang/nuxt-layer-test-bug
Describe the bug
When project root is using Nuxt 4 version (via config
future.compatibilityVersion = 4), nuxt test utils would not work on layers within same project.The unit test would run without console error log, but the test report would show there is an error:
When project root is not using Nuxt 4 version, the nuxt test utils would work as expected.
See reproduction repo:
Additional context
No response
Logs