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 摘要。