Skip to content

Karma builder ignores assets directory with "builderMode: application" #28754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task
cexbrayat opened this issue Oct 31, 2024 · 1 comment · Fixed by #28795
Closed
1 task

Karma builder ignores assets directory with "builderMode: application" #28754

cexbrayat opened this issue Oct 31, 2024 · 1 comment · Fixed by #28795

Comments

@cexbrayat
Copy link
Member

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

The karma builder has an option to define a assets directories.
By default, it uses: {"glob": "**/*", "input": "public" }.

When using "builderMode: application", this option is ignored and the Karma server throws 404 for the assets used in tested components.

Minimal Reproduction

Generate a new project with npx @angular/cli@19.0.0-rc.0 new karma-assets --defaults --no-routing.
Add "builderMode": "application", to angular.json in the karma options.
Rename public/favicon.ico to public/favicon.png.
Replace the app.component.html template with <img src="favicon.png" alt="Angular Logo" />.
Replace the app.component.spec.ts with:

import { TestBed } from '@angular/core/testing';
import { AppComponent } from './app.component';

describe('AppComponent', () => {
  beforeEach(() => TestBed.configureTestingModule({}));

  it('should create the app', () => {
    const fixture = TestBed.createComponent(AppComponent);
    fixture.detectChanges();
    expect(fixture.componentInstance).toBeTruthy();
  });
});

Launch ng test

Exception or Error

31 10 2024 07:20:02.816:WARN [karma]: No captured browser, open http://localhost:9876/
31 10 2024 07:20:02.825:INFO [karma-server]: Karma v6.4.4 server started at http://localhost:9876/
31 10 2024 07:20:02.825:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
31 10 2024 07:20:02.827:INFO [launcher]: Starting browser ChromeHeadless
31 10 2024 07:20:03.544:INFO [Chrome Headless 130.0.0.0 (Mac OS 10.15.7)]: Connected on socket V7qJDTy8680sTot9AAAB with id 30066879
31 10 2024 07:20:03.699:WARN [web-server]: 404: /favicon.png

Your Environment

Angular CLI: 19.0.0-rc.0
Node: 20.13.1
Package Manager: npm 9.7.1
OS: darwin arm64

Angular: 19.0.0-rc.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.1900.0-rc.0
@angular-devkit/build-angular 19.0.0-rc.0
@angular-devkit/core 19.0.0-rc.0
@angular-devkit/schematics 19.0.0-rc.0
@schematics/angular 19.0.0-rc.0
rxjs 7.8.1
typescript 5.6.3
zone.js 0.15.0

Anything else relevant?

No response

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants