Skip to content
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

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

Closed
1 task
cheng93 opened this issue Feb 2, 2023 · 2 comments · Fixed by #24655
Closed
1 task

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

cheng93 opened this issue Feb 2, 2023 · 2 comments · Fixed by #24655

Comments

@cheng93
Copy link

cheng93 commented Feb 2, 2023

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

@alan-agius4
Copy link
Collaborator

This seems to have regressed in the last patch version following #24620

@alan-agius4 alan-agius4 self-assigned this Feb 3, 2023
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Feb 3, 2023
…ipts instead of modules

This commit updates changes the way polyfills and runtime are loaded from modules to scripts. This is required as otherwise Jasmine will be loaded prior to Zone.js which causes clock patching not to work.

Closes angular#24651
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Feb 3, 2023
…ipts instead of modules

This commit updates changes the way polyfills and runtime are loaded from modules to scripts. This is required as otherwise Jasmine will be loaded prior to Zone.js which causes clock patching not to work.

Closes angular#24651
angular-robot bot pushed a commit that referenced this issue Feb 3, 2023
…ipts instead of modules

This commit updates changes the way polyfills and runtime are loaded from modules to scripts. This is required as otherwise Jasmine will be loaded prior to Zone.js which causes clock patching not to work.

Closes #24651

(cherry picked from commit bf3be56)
angular-robot bot pushed a commit that referenced this issue Feb 3, 2023
…ipts instead of modules

This commit updates changes the way polyfills and runtime are loaded from modules to scripts. This is required as otherwise Jasmine will be loaded prior to Zone.js which causes clock patching not to work.

Closes #24651
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Feb 8, 2023
…ipts instead of modules

This commit updates changes the way polyfills and runtime are loaded from modules to scripts. This is required as otherwise Jasmine will be loaded prior to Zone.js which causes clock patching not to work.

Closes angular#24651
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Feb 9, 2023
…ipts instead of modules

This commit updates changes the way polyfills and runtime are loaded from modules to scripts. This is required as otherwise Jasmine will be loaded prior to Zone.js which causes clock patching not to work.

Closes angular#24651
@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 Mar 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants