getVitestConfigFromNuxt returns empty viteConfig on Nuxt 4.6 + Vite 8 (rolldown) — nuxt environment tests fail with Missing "#app/..." specifier
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- nodejs, typescript
- Lĩnh vực
- build-system, testing
Hướng nghiên cứu
Start with getVitestConfigFromNuxt and startNuxtAndGetViteConfig in @nuxt/test-utils (config.mjs), which capture the config through the vite:configResolved hook. Run the repro script from the issue against a Nuxt 4.6 fixture to confirm the captured config is empty, then check how Nuxt's Vite 8 builder now exposes per-environment configs. Done when viteConfig.resolve.alias contains #app and #build, and a trivial nuxt environment test imports successfully.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Environment
- Nuxt: 4.6.0
- Vite: 8.3.4 (rolldown-vite)
- Vitest: 4.1.11
- @nuxt/test-utils: 4.3.4 (latest; also reproduced on 4.3.2)
- Node: 22.23.4
- OS: Linux
Description
On Nuxt 4.6 + Vite 8 (rolldown), getVitestConfigFromNuxt captures an empty object as the Vite config. As a result, #app/#build aliases and Nuxt's virtual-module plugins are never registered in the test Vite server, and every test file using the nuxt environment fails at import time:
Error: Missing "#app/composables/router" specifier in "@nuxt/test-utils" package
Plugin: vite:import-analysis
(#app/... falls through to package-imports resolution of @nuxt/test-utils because no alias matched.)
Minimal reproduction
// repro.mjs — run from any Nuxt 4.6 project root
const mod = await import('@nuxt/test-utils/dist/config.mjs')
const cfg = await mod.getVitestConfigFromNuxt(undefined, { overrides: { rootDir: process.cwd() } })
console.log('viteConfig keys:', Object.keys(cfg.viteConfig || {}))
console.log('resolve.alias present:', !!cfg.viteConfig?.resolve?.alias)
Expected: viteConfig contains Nuxt's client Vite config, including resolve.alias with #app, #build, ~, etc.
Actual:
viteConfig keys: []
resolve.alias present: false
Also reproduced with nitroEnvironment: true, and with both the app root and a minimal fixture (rootDir override). Reproduced with any trivial nuxt environment test file, e.g.:
// test/probe.test.ts
import { it } from 'vitest'
import { useNuxtApp } from '#app'
it('probe', () => { console.log(Object.keys(useNuxtApp())) })
// vitest.config.ts
import { defineVitestConfig } from '@nuxt/test-utils/config'
export default defineVitestConfig({ test: {} })
Analysis
getVitestConfigFromNuxt captures the config via the vite:configResolved hook (startNuxtAndGetViteConfig). With Nuxt 4.6's Vite 8 builder (@nuxt/vite-builder), the hook fires but the captured config has zero keys. Nuxt 4.6's builder now constructs per-environment configs (environments.client / environments.ssr, see vite-builder clientEnvironment() and the strippedConfig hook invocation in the build path), so the top-level Vite config shape test-utils expects appears to have moved.
Happy to provide more diagnostics if useful.
- Ngôn ngữ chính
- TypeScript
- Star
- 445
- Fork
- 121
- Merge trung bình
- 3 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 23
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của nuxt/test-utils
-
nuxt environment: `fetch(new Request(url))` fails with `Failed to parse URL from [object Request]`Có thể đã có người làm @yamachi4416 đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
nuxt/test-utils#1891 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
nuxt/test-utils#1889 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
pending triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
nuxt/test-utils#1671 · 5 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
-
pending triage
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
nuxt/test-utils#1607 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
`@vitest-environment-options` is not workingCó thể đã có người làm @yamachi4416 đã nhận 210 ngày trước. Đang mởpending triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
nuxt/test-utils#1541 · 2 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của nuxt/test-utils
Issue tương tự
-
bug priority: low role: BE stage: now
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
ahmadrosid/nakama#2594 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
milind-soni/OpenMausBot#6495 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Navigating the session tree adds the branch's prompts to Up-arrow history againCó thể đã có người làm @acmerfight đã nhận hôm nay. Đang mởuntriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
earendil-works/pi#12279 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
approved documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 89/100
vitest-dev/vitest#12015 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày