angular / angular/angular-cli

The unit-test builder doesn't re-run test suites on changes to non-spec files

Đang mở
#32,159 1 bình luận 3 reaction 0 người được giao Được @maruthang nhận Xem trên GitHub
angular/build:unit-test freq1: low severity3: broken type: bug/fix
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ả

### 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

_No response_

### Description

Storybook has support for running component tests using Vitest. When trying to build a POC with the `unit-test` builder, I ran into two issues.

- Storybook can't transform the stories because the compiled code leads to file with just an`import` as its contents.
- Making changes to files that aren't in the `include` array doesn't trigger tests to be re-run.

I was able to work around the code import issue with a plugin that re-exports the chunks from compiled files
https://github.com/brandonroberts/angular-storybook-vitest/blob/main/vitest-storybook-base.config.ts#L16

### Minimal Reproduction

https://github.com/brandonroberts/angular-storybook-vitest

1. Clone and install dependencies
2. Run `npm run test-storybook`
3. Note the tests pass
4. Make a change in one of the `src/stories/*.stories.ts` files
5. Note the build re-compiles but the tests aren't re-run.

The `test-storybook` target excludes the `stories` files because of the import issue so they are transpiled as-is.

https://github.com/brandonroberts/angular-storybook-vitest/blob/main/angular.json#L94

### Exception or Error

```text
No exception
```

### Your Environment

```text
Angular v21
```

### Anything else relevant?

_No response_

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

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

Hướng nghiên cứu

Bắt đầu với reproduction đã được liên kết, angular.json test-storybook target của nó và npm run test-storybook. Thay đổi một story không được include hoặc một file liên quan khác, rồi quan sát xem build có biên dịch lại mà không chạy lại các bài kiểm tra hay không. Hoàn tất khi các thay đổi đối với các file nằm ngoài include array kích hoạt lại test suite; một pull request đang mở đã được liên kết với issue này.

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
build-system, testing
Loại issue
Lỗi
Độ 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
25/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.