Skip to content

angular/cli 22.1.0 fails to run tests using karma test runner #33678

Description

@daddyman

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

22.0.9

Description

My app is still using karma to run tests. On angular and cli 22.0.8/22.0.9 the unit tests run fine. I updated to 22.1.0 and the unit tests fail to compile saying that the spec.ts files cannot be found during compilation.

I created a new angular project using ng 22.1.0 and the karma test runner and see the same error.

Minimal Reproduction

  • angular/cli 22.1.0 is installed globally: ng --version prints out 22.1.0. I am using node 26.5.1.

  • Run ng new foo --test-runner=karma to create a new project.

  • In the foo folder run npm test. The test fails to build. See error below.

Exception or Error

Application bundle generation failed. [2.736 seconds] - 2026-07-30T01:18:54.768Z

✘ [ERROR] File 'src\app\app.spec.ts' not found in TypeScript compilation. [plugin angular-compiler]

  Files containing Angular metadata ('@Component'/'@Directive'/etc.) must be part of the TypeScript compilation. You can ensure the file is part of the TypeScript program via the 'files' or 'include' property.

Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI       : 22.1.0
Angular           : 22.1.0
Node.js           : 26.5.1
Package Manager   : npm 11.17.0
Operating System  : win32 x64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build            │ 22.1.0            │ ^22.1.0           │
│ @angular/cli              │ 22.1.0            │ ^22.1.0           │
│ @angular/common           │ 22.1.0            │ ^22.1.0           │
│ @angular/compiler         │ 22.1.0            │ ^22.1.0           │
│ @angular/compiler-cli     │ 22.1.0            │ ^22.1.0           │
│ @angular/core             │ 22.1.0            │ ^22.1.0           │
│ @angular/forms            │ 22.1.0            │ ^22.1.0           │
│ @angular/platform-browser │ 22.1.0            │ ^22.1.0           │
│ @angular/router           │ 22.1.0            │ ^22.1.0           │
│ rxjs                      │ 7.8.2             │ ~7.8.0            │
│ typescript                │ 6.0.3             │ ~6.0.2            │
└───────────────────────────┴───────────────────┴───────────────────┘

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions