angular / angular/angular-cli

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

未關閉
#32,159 1 則留言 3 個 reaction 已指派 0 人 已被 @maruthang 認領 在 GitHub 檢視
angular/build:unit-test freq1: low severity3: broken type: bug/fix
主要語言
TypeScript
星號
27k
分支
11.8k
平均合併
14 小時 23 分鐘
30 天內合併 PR
162

描述

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

貢獻指南

開啟貢獻指南

研究方向

從已連結的重現、其 angular.json test-storybook target 以及 npm run test-storybook 開始。修改一個未包含的 story 或其他相關檔案,並觀察 build 是否會重新編譯而不重新執行測試。只有當對 include array 之外的檔案所做的變更會再次觸發測試套件時,才算完成;此 issue 已經連結了一個開啟中的 pull request。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
angular, typescript
領域
build-system, testing
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。