ng test fails with NG8001 in a new NgModule app on 22.2.0
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- angular, typescript
- Lĩnh vực
- build-system, testing-qa
Hướng nghiên cứu
Reproduce the failure with the provided ng test command, then inspect the Vitest runner behavior described since #34134, starting with app.spec.ts, app-module.ts, and tsconfig.spec.json. Trace which files are compiled through imports and verify the generated NgModule app passes on 22.2.0 without adding an import workaround.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Command
test
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
22.1.9
Description
In a new NgModule app, ng test fails on 22.2.0 with NG8001 for <router-outlet>. The same app generated with 22.1.9 passes.
Since #34134, the Vitest runner compiles the spec files, the setup and providers files, and the files they import. No spec imports app-module.ts, so it is not compiled, even though tsconfig.spec.json includes it.
Minimal Reproduction
npx @angular/[email protected] new repro --standalone=false --defaults
cd repro
npx ng test --watch=false
The generated app is not changed. src/app/app.html ends with <router-outlet />.
With @angular/[email protected], the same app passes (1 test file, 2 tests) when the @angular/* packages are pinned to ~22.1.0 before installing.
Adding import './app-module' at the top of src/app/app.spec.ts makes the tests pass on 22.2.0. Adding src/app/app-module.ts to files in tsconfig.spec.json does not.
Exception or Error
Application bundle generation failed. [1.373 seconds]
✘ [ERROR] NG8001: 'router-outlet' is not a known element:
1. If 'router-outlet' is an Angular component, then verify that it is part of this module.
2. If 'router-outlet' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. Find more at https://next.angular.dev/errors/NG8001 [plugin angular-compiler]
src/app/app.html:344:0:
344 │ <router-outlet />
╵ ~~~~~~~~~~~~~~~~~
Error occurs in the template of component App.
src/app/app.ts:7:15:
7 │ templateUrl: './app.html',
╵ ~~~~~~~~~~~~
Your Environment
Angular CLI : 22.2.0
Angular : 22.2.0
Node.js : 26.7.0
Package Manager : npm 11.19.0
Operating System : darwin arm64
┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build │ 22.2.0 │ ^22.2.0 │
│ @angular/cli │ 22.2.0 │ ^22.2.0 │
│ @angular/common │ 22.2.0 │ ^22.2.0 │
│ @angular/compiler │ 22.2.0 │ ^22.2.0 │
│ @angular/compiler-cli │ 22.2.0 │ ^22.2.0 │
│ @angular/core │ 22.2.0 │ ^22.2.0 │
│ @angular/forms │ 22.2.0 │ ^22.2.0 │
│ @angular/platform-browser │ 22.2.0 │ ^22.2.0 │
│ @angular/router │ 22.2.0 │ ^22.2.0 │
│ rxjs │ 7.8.2 │ ~7.8.0 │
│ typescript │ 6.0.3 │ ~6.0.2 │
│ vitest │ 5.0.3 │ ^5.0.0 │
└───────────────────────────┴───────────────────┴───────────────────┘
- Ngôn ngữ chính
- TypeScript
- Star
- 27k
- Fork
- 11.8k
- Merge trung bình
- 23 giờ 27 phút
- Pull request đã merge (30 ngày)
- 152
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- 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 angular/angular-cli
-
Can't use an array of hostnames in --allowedHosts cli parameter in @angular/build:dev-serverĐang mởarea: @angular/build gemini-triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
angular/angular-cli#33955 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: @angular/cli gemini-triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
angular/angular-cli#33055 · 1 bình luận · 3 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: @angular/build
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 65/100
angular/angular-cli#34257 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add CSP nonce to <link rel="stylesheet"> tags when ngCspNonce is setCó thể đã có người làm @alan-agius4 đã nhận hôm nay. Đang mởarea: @angular/build
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
angular/angular-cli#34255 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: @angular/build
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
angular/angular-cli#34250 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của angular/angular-cli
Issue tương tự
-
dx hacktoberfest help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
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 68/100
cloudflare/agents#2498 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Missing repro Platform: Android
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
software-mansion/react-native-reanimated#10816 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
e2e-failure ready-to-code
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
redhat-developer/rhdh-plugin-export-overlays#4129 ·
Maintainer thường phản hồi trong vòng 1 ngày