#is `@angular/build:unit-test` supposed to work with `@angular-devkit/build-angular:ng-packagr`

1 messages · Page 1 of 1 (latest)

icy minnow
#

Basically title - see the angular.json

{
  "$schema": "../../../../../node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "cli": { "analytics": false, "cache": { "enabled": false } },
  "projects": {
    "lib": {
      "projectType": "library",
      "root": "",
      "sourceRoot": "src",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:ng-packagr",
          "options": {
            "tsConfig": "tsconfig.build.json",
            "project": "ng-package.json"
          }
        },
        "test": {
          "builder": "@angular/build:unit-test",
          "options": {
            "buildTarget": ":build",
            "tsConfig": "tsconfig.spec.json",
            "browsers": ["chromium"],
            "coverage": true
          },
          "defaultConfiguration": "development",
          "configurations": {
            "development": { "ui": true },
            "ci": { "watch": false }
          }
        }
      },
      "schematics": { "@schematics/angular:component": { "style": "scss" } }
    }
  }
}

It does work locally, however in CI the agent freezes with output:

> ng test --configuration=ci

The 'buildTarget' is configured to use '@angular-devkit/build-angular:ng-packagr', which is not supported. The 'unit-test' builder is designed to work with '@angular/build:application'. Unexpected behavior or build failures may occur.
❯ Building...
✔ Building...
Initial chunk files | Names         | Raw size
chunk-XSGC6WRG.js   | -             |  4.05 kB | 
spec-header.js      | spec-header   |  1.95 kB | 
init-testbed.js     | init-testbed  |  1.20 kB | 

                    | Initial total |  7.20 kB

Application bundle generation complete. [1.416 seconds] - 2025-12-09T18:00:12.650Z


 RUN  v4.0.15 /__w/1/s/libs/xyz
      Coverage enabled with v8
granite dove
#

Given that the error message says that it's not supported, I think it's safe to say that the answer to your question is no.