Nuxt 4 + Layers breaks Nuxt Test Utils
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 437
- Forks
- 120
- Avg merge
- 22h 52m
- Merged PRs (30d)
- 23
Description
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:
- Github: https://github.com/wuiyang/nuxt-layer-test-bug/tree/working-without-nuxt-4
- Stackblitz: https://stackblitz.com/~/github.com/wuiyang/nuxt-layer-test-bug/tree/working-without-nuxt-4?file=package.json
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction repository and its package.json, comparing the working-without-nuxt-4 branch with the configuration using future.compatibilityVersion = 4. Run npx vitest run --coverage and verify that tests for layers complete without the undefined vueApp error and produce a valid report.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxtjs, typescript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100