Skip to content

Karma builder issue with jasmine.clock() with "builderMode: application" #28813

@cexbrayat

Description

@cexbrayat

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 using jasmine.clock(), tests are throwing with the application builder

Minimal Reproduction

Generate a new project with npx @angular/cli@19.0.0-rc.1 new karma-clock --defaults --no-routing
Update the test app.component.spec.ts with:

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      imports: [AppComponent],
    }).compileComponents();
    jasmine.clock().install();
  });

  afterEach(() => jasmine.clock().uninstall());

Run the test: everything is fine.

Add "builderMode": "application", to angular.json in the karma options.
Run ng test again, the tests fail

Exception or Error

07 11 2024 18:11:04.827:INFO [Chrome 130.0.0.0 (Mac OS 10.15.7)]: Connected on socket cJzDaksNAB24vLcmAAAB with id 93837966
Chrome 130.0.0.0 (Mac OS 10.15.7) AppComponent should render title FAILED
Error: Jasmine Clock was unable to install over custom global timer functions. Is the clock already installed?

Your Environment

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

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

Package Version

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

Anything else relevant?

No response

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions