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

Open
#32,159 1 comment 3 reactions 0 assignees View on GitHub

@maruthang is already working on this.

Since Mar 27, 2026.

  • #32884 by @maruthang — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
angular, typescript

Research direction

Start with the linked reproduction, its angular.json test-storybook target, and npm run test-storybook. Change a non-included story or other relevant file and observe whether the build recompiles without rerunning tests. Done means changes to files outside the include array trigger the test suite again; an open pull request is already linked to this issue.

Written by the indexing model from the issue text.

Description

angular/build:unit-test freq1: low severity3: broken type: bug/fix
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 animport 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
No exception
Your Environment
Angular v21
Anything else relevant?

No response

Dominant language
TypeScript
Stars
27k
Forks
11.8k
Avg merge
16h 35m
Merged PRs (30d)
176

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from angular/angular-cli

All issues in angular/angular-cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.