Skip to content

@angular/build:unit-test does not include global styles.css file #30444

Closed
@wein2011

Description

@wein2011

Command

build

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

@angular/build:karma

Description

The application includes global styles in angular.json:

architect.build.styles: ["src/custom-theme.scss", "src/styles.css"]

Karma (@angular/build:karma) serves the resulting global styles.css as

http://localhost:9876/base/styles.css

and includes it into the html file of the test iframe.

Similary, Vitest (@angular/build:unit-test) builds the global styles.css and servers it as

http://localhost:63315/styles.css

However, Vitest does not include it into the html file of the test iframe.

Due to the missing styles, some of the tests fail using the chromium browser.

Minimal Reproduction

In angular.json:
Include global styles

architect.build.styles: ["src/custom-theme.scss", "src/styles.css"]

Include chromium browser

architect.test.options.browsers: ["chromium"]

Execute test

Validate that dist\test-out\HASH folder includes styles.css

Open chromium and check if any of the global styles from styles.css have been applied to the tests

Exception or Error


Your Environment

Angular CLI: 20.0.0
Node: 22.16.0
Package Manager: npm 10.9.2
OS: win32 x64

Angular: 20.0.0
... animations, build, cli, common, compiler, compiler-cli, core
... forms, language-service, platform-browser
... platform-browser-dynamic, router

Package                              Version
--------------------------------------------------------------
@angular-devkit/architect            0.2000.0
@angular-devkit/core                 20.0.0
@angular-devkit/schematics           20.0.0
@angular/cdk                         20.0.1
@angular/material                    20.0.1
@angular/material-date-fns-adapter   20.0.1
@schematics/angular                  20.0.0
rxjs                                 7.8.2
typescript                           5.8.3

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions