angular / angular/angular-cli

alternatives to change TestBed configurations without creating the test.ts files

Đang mở
#24,345 6 bình luận 5 reaction 0 người được giao Xem trên GitHub
area: @angular-devkit/build-angular devkit/build-angular:karma feature feature: insufficient votes
Ngôn ngữ chính
TypeScript
Star
27k
Fork
11.8k
Merge trung bình
14 giờ 23 phút
Pull request đã merge (30 ngày)
162

Mô tả

### Which @angular/* package(s) are relevant/related to the feature request?

core

### Description

with Angular 15, now the `test.ts` file doesn't get generated by default, so it's not an easy task to change the `TestBed` configurations for example to enable `errorOnUnknownElements`
it will also be nice if we can change the pattern of the tests

### Proposed solution

to add the configurations inside the `angular.json` files in the options section of test

something like

```
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": [],
"errorOnUnknownElements": true, <---
"errorOnUnknownProperties": true, <---
"pattern": "\.custom-spec\.ts$" <---
}
```

### Alternatives considered

to be able to enable them globally from any script (to create a js file and add it to the scripts of the test) with something like

```
getTestBed().setoptions({
errorOnUnknownElements: true,
errorOnUnknownProperties: true,
pattern: /\.custom-spec\.ts$/
});
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách lần theo cách các tùy chọn kiểm thử trong angular.json được xử lý và cách bootstrap của test.ts được tạo hoặc thay thế. Sử dụng các thiết lập TestBed được yêu cầu và mẫu kiểm thử tùy chỉnh làm các trường hợp chấp nhận; công việc được xem là hoàn tất khi các project có thể cấu hình chúng mà không cần tạo các tệp test.ts.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
testing, tooling
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.