Skip to content

ng test error: "asset path must start with the project source root" #32326

@nw1n

Description

@nw1n

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

21.0.5

Description

We use the following asset paths config in ng-package.json in our library project:

"assets": ["./**/*.scss", "src/assets/i18n"],

Now this always worked fine, and even in 21.1.0 the library builds correctly and can be used in our demo, but since 21.1.0 ng test fails with Error: The ./**/*.scss asset path must start with the project source root.

The weird thing is, that project builds and runs perfectly as before, only ng test throws this error concerning project root source.

> ng test 

An exception occurred while creating the test executor:
Error: The ./**/*.scss asset path must start with the project source root.
    at /node_modules/@angular/build/src/utils/normalize-asset-patterns.js:71:23
    at Array.map (<anonymous>)
    at normalizeAssetPatterns (/node_modules/@angular/build/src/utils/normalize-asset-patterns.js:64:26)
    at normalizeOptions (/node_modules/@angular/build/src/builders/application/options.js:77:46)
    at async buildApplicationInternal (/node_modules/@angular/build/src/builders/application/index.js:86:31)
    at async runBuildAndTest (/node_modules/@angular/build/src/builders/unit-test/builder.js:158:22)
    at async execute (/node_modules/@angular/build/src/builders/unit-test/builder.js:330:13)
    at async handleAsyncIterator (/node_modules/@angular-devkit/architect/src/api.js:38:28)

Minimal Reproduction

We use the following asset paths config in ng-package.json in our library project:

"assets": ["./**/*.scss", "src/assets/i18n"],

Then we run ng test.

Exception or Error

An exception occurred while creating the test executor:
Error: The ./**/*.scss asset path must start with the project source root.
    at /node_modules/@angular/build/src/utils/normalize-asset-patterns.js:71:23
    at Array.map (<anonymous>)
    at normalizeAssetPatterns (/node_modules/@angular/build/src/utils/normalize-asset-patterns.js:64:26)
    at normalizeOptions (/node_modules/@angular/build/src/builders/application/options.js:77:46)
    at async buildApplicationInternal (/node_modules/@angular/build/src/builders/application/index.js:86:31)
    at async runBuildAndTest (/node_modules/@angular/build/src/builders/unit-test/builder.js:158:22)
    at async execute (/node_modules/@angular/build/src/builders/unit-test/builder.js:330:13)
    at async handleAsyncIterator (/node_modules/@angular-devkit/architect/src/api.js:38:28)

Your Environment

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

Angular CLI       : 21.1.0
Angular           : 21.0.8
Node.js           : 22.21.1
Package Manager   : npm 10.9.4
Operating System  : darwin arm64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/animations       │ 21.0.8            │ ^21.0.8           │
│ @angular/build            │ 21.1.0            │ ^21.1.0           │
│ @angular/cdk              │ 21.0.6            │ ^21.0.6           │
│ @angular/cli              │ 21.1.0            │ ^21.1.0           │
│ @angular/common           │ 21.0.8            │ ^21.0.8           │
│ @angular/compiler         │ 21.0.8            │ ^21.0.8           │
│ @angular/compiler-cli     │ 21.0.8            │ ^21.0.8           │
│ @angular/core             │ 21.0.8            │ ^21.0.8           │
│ @angular/forms            │ 21.0.8            │ ^21.0.8           │
│ @angular/material         │ 21.0.6            │ ^21.0.6           │
│ @angular/platform-browser │ 21.0.8            │ ^21.0.8           │
│ @angular/router           │ 21.0.8            │ ^21.0.8           │
│ ng-packagr                │ 21.0.0            │ ^21.0.0           │
│ rxjs                      │ 7.8.2             │ ~7.8.0            │
│ typescript                │ 5.9.3             │ ~5.9.3            │
│ vitest                    │ 4.0.14            │ ^4.0.14           │
│ zone.js                   │ 0.15.1            │ ^0.15.1           │
└───────────────────────────┴───────────────────┴───────────────────┘

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions