angular / angular/angular-cli

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

Offen
#32,159 1 Kommentar 3 Reaktionen 0 zugewiesene Personen Beansprucht von @maruthang Auf GitHub ansehen
angular/build:unit-test freq1: low severity3: broken type: bug/fix
Vorherrschende Sprache
TypeScript
Sterne
27k
Forks
11.8k
Ø Merge
14 Std. 23 Min.
Gemergte PRs (30 T.)
162

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit der verlinkten Reproduktion, ihrem angular.json test-storybook target und npm run test-storybook. Ändere eine nicht eingeschlossene Story oder eine andere relevante Datei und beobachte, ob der Build neu kompiliert wird, ohne die Tests erneut auszuführen. Erledigt ist es, wenn Änderungen an Dateien außerhalb des include array die Testsuite erneut auslösen; ein offener pull request ist bereits mit diesem Issue verknüpft.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
build-system, testing
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.