Skip to content

Jasmine's clock mocks can't be used in library specs v2 #24651

Closed
@cheng93

Description

@cheng93

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

I do not believe #14432 was fixed

Minimal Reproduction

npm install -g @angular/cli
ng new ngtest1

added to app.component.spec.ts

beforeEach(() => {
    jasmine.clock().install();
  });

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

Exception or Error

Chrome 109.0.0.0 (Windows 10) AppComponent should render title FAILED
        Error: Jasmine Clock was unable to install over custom global timer functions. Is the clock already installed?
            at <Jasmine>
            at UserContext.apply (src/app/app.component.spec.ts:14:21)
            at _ZoneDelegate.invoke (node_modules/zone.js/fesm2015/zone.js:375:26)
            at ProxyZoneSpec.onInvoke (node_modules/zone.js/fesm2015/zone-testing.js:287:39)
            at _ZoneDelegate.invoke (node_modules/zone.js/fesm2015/zone.js:374:52)
            at Zone.run (node_modules/zone.js/fesm2015/zone.js:134:43)
            at runInTestZone (node_modules/zone.js/fesm2015/zone-testing.js:582:34)
            at UserContext.<anonymous> (node_modules/zone.js/fesm2015/zone-testing.js:597:20)
            at <Jasmine>

Your Environment

Angular CLI: 15.1.4
Node: 18.12.1
Package Manager: npm 8.19.2
OS: win32 x64

Angular: 15.1.2
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1501.4
@angular-devkit/build-angular   15.1.4
@angular-devkit/core            15.1.4
@angular-devkit/schematics      15.1.4
@angular/cli                    15.1.4
@schematics/angular             15.1.4
rxjs                            7.8.0
typescript                      4.9.5

Anything else relevant?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions