-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
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
I am using the experimental Jest support with Angular 19 and am having troubles getting my library tests to run. Tests for a regular app work fine if the libraries are placed in the src folder; otherwise, it will have the same issue. The libraries still fail with that setup.
The issue:
ng test doesn't run and prints the following error for each .spec.ts file in the other libraries
For example, if I run ng test lib, it fails with this error about the app.spec.ts file in the main application, which shouldn't need to be in the TS compilation because I'm running tests for just lib.
X [ERROR] File 'src\app\app.spec.ts' is missing from the TypeScript compilation. [plugin angular-compiler]
Ensure the file is part of the TypeScript program via the 'files' or 'include' property.
For now, I just have my libraries in the src folder, removed testing from the library architects, and just have the main app test the child libraries.
Minimal Reproduction
npm i -g @angular/cli@19.0.5ng new jest-lib-test --routing true --style scss --ssr falsecd jest-lib-testnpm r @types/jasmine jasmine-core karma karma-chrome-launcher karma-coverage karma-jasmine karma-jasmine-html-reporternpm i -D jest @types/jest jest-preset-angularng g library lib- Replace
jasminewithjestintsconfig.spec.jsonandprojects/lib/tsconfig.spec.json - Replace
karmawithjestinangular.json(both test configs) - Remove
inlineStyleLanguage,assets,styles, andscriptsfrom the app's test config while you're inangular.json ng test
Exception or Error
NOTE: The Jest builder is currently EXPERIMENTAL and not ready for production use.
Application bundle generation failed. [1.050 seconds]
X [ERROR] File 'projects\lib\src\lib\lib.service.spec.ts' is missing from the TypeScript compilation. [plugin angular-compiler]
Ensure the file is part of the TypeScript program via the 'files' or 'include' property.
X [ERROR] File 'projects\lib\src\lib\lib.component.spec.ts' is missing from the TypeScript compilation. [plugin angular-compiler]
Ensure the file is part of the TypeScript program via the 'files' or 'include' property.
NOTE: The Jest builder is currently EXPERIMENTAL and not ready for production use.
Application bundle generation failed. [0.846 seconds]
X [ERROR] File 'src\app\app.component.spec.ts' is missing from the TypeScript compilation. [plugin angular-compiler]
Ensure the file is part of the TypeScript program via the 'files' or 'include' property.
Your Environment
Angular CLI: 19.2.0
Node: 20.18.0
Package Manager: npm 11.1.0
OS: win32 x64
Angular: 19.2.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1902.0
@angular-devkit/build-angular 19.2.0
@angular-devkit/core 19.2.0
@angular-devkit/schematics 19.2.0
@schematics/angular 19.2.0
ng-packagr 19.2.0
rxjs 7.8.2
typescript 5.6.3
zone.js 0.15.0
Anything else relevant?
On Windows 11