-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Open
Labels
angular/build:unit-testarea: @angular/buildfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyseverity3: brokentype: bug/fix
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
When a test errors with the vitest runner in browser mode, a screenshot is generated in a __screenshots__
directory. Running ng test
with such a screenshot in that directory produces:
✘ [ERROR] No loader is configured for ".png" files: src/app/__screenshots__/app.spec.ts/App-should-render-title-1.png
Minimal Reproduction
npx @angular/cli@next new vitest-screenshots --defaults --no-routing
cd vitest-screenshots
npm i --save-dev --save-exact vitest @vitest/browser
Update angular.json
to use:
"test": {
"builder": "@angular/build:unit-test",
"options": {
"tsConfig": "tsconfig.spec.json",
"buildTarget": "::development",
"runner": "vitest",
"browsers": ["ChromiumHeadless"]
}
}
Update the app.spec.ts
file to fail the test.
ng test --no-watch
# test fails and a screenshot is generated
ng test --no-watch
# throws the mentioned error
Exception or Error
❯ ng test
NOTE: The "unit-test" builder is currently EXPERIMENTAL and not ready for production use.
Application bundle generation failed. [1.285 seconds] - 2025-09-23T18:44:28.548Z
✘ [ERROR] No loader is configured for ".png" files: src/app/__screenshots__/app.spec.ts/App-should-render-title-1.png
Your Environment
Angular CLI: 21.0.0-next.4
Node: 22.18.0
Package Manager: npm 10.9.0
OS: darwin arm64
Angular: 21.0.0-next.4
... build, cli, common, compiler, compiler-cli, core, forms
... platform-browser, router
Package Version
------------------------------------
@angular-devkit/architect 0.2100.0-next.4
@angular-devkit/core 21.0.0-next.4
@angular-devkit/schematics 21.0.0-next.4
@schematics/angular 21.0.0-next.4
rxjs 7.8.2
typescript 5.9.2
zone.js 0.15.1
Anything else relevant?
I'm willing to open a PR to fix that, but I'm wondering what the best approach should be.
Metadata
Metadata
Assignees
Labels
angular/build:unit-testarea: @angular/buildfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyseverity3: brokentype: bug/fix