Skip to content

fix(@angular/build): only compile included test files in unit-test builder - #34134

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:fix-unit-test-include-compilation
Sep 22, 2026
Merged

alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:fix-unit-test-include-compilation

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

When running the unit-test builder with --include, TypeScript compilation previously compiled all test files matched by the tsconfig file, causing compilation errors in unrelated test files to fail the test run.

This change introduces a rootFiles option that restricts the TypeScript program's root files to only the test files to be executed (plus setup files and providers), while preserving ambient .d.ts declaration files discovered by readConfiguration.

Fixes #34089

@alan-agius4 alan-agius4 added the target: rc This PR is targeted for the next release-candidate label Sep 21, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a rootFiles option to the Angular application builder and compiler options, allowing the TypeScript compilation to restrict its root names to only the specified files (such as test, setup, and provider files). This change prevents compilation errors in non-included test files during unit testing. The feedback suggests ensuring that if a custom main file is provided in the Karma options, it is also included in the rootFiles list to avoid compilation warnings or errors.

Comment thread packages/angular/build/src/builders/karma/application_builder.ts Outdated
@alan-agius4
alan-agius4 force-pushed the fix-unit-test-include-compilation branch 2 times, most recently from 5f80743 to 3317656 Compare September 21, 2026 13:18
@alan-agius4
alan-agius4 requested a review from clydin September 21, 2026 17:49
@alan-agius4 alan-agius4 self-assigned this Sep 21, 2026
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer and removed area: @angular/build labels Sep 21, 2026
@alan-agius4
alan-agius4 force-pushed the fix-unit-test-include-compilation branch from 3317656 to d492fce Compare September 21, 2026 17:54
@alan-agius4 alan-agius4 removed their assignment Sep 22, 2026
@alan-agius4
alan-agius4 force-pushed the fix-unit-test-include-compilation branch 3 times, most recently from 78b801b to 195d9e3 Compare September 22, 2026 14:43
Comment thread packages/angular/build/src/tools/angular/compilation/typescript-compilation.ts Outdated
…ilder

When running the `unit-test` builder with `--include`, TypeScript compilation previously compiled all test files matched by the tsconfig file, causing compilation errors in unrelated test files to fail the test run.

This change introduces a `rootFiles` option that restricts the TypeScript program's root files to only the test files to be executed (plus setup files and providers), while preserving ambient `.d.ts` declaration files discovered by `readConfiguration`.

Fixes angular#34089
@alan-agius4
alan-agius4 force-pushed the fix-unit-test-include-compilation branch from 195d9e3 to aeb7fc3 Compare September 22, 2026 15:04
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Sep 22, 2026
@alan-agius4
alan-agius4 merged commit 5e05373 into angular:main Sep 22, 2026
40 checks passed
@alan-agius4
alan-agius4 deleted the fix-unit-test-include-compilation branch September 22, 2026 15:21
@alan-agius4

Copy link
Copy Markdown
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: rc This PR is targeted for the next release-candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running @angular/build:unit-test with --include= should only compile the included tests

2 participants