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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular9: Jest + Ivy without Zone (noNgZone). #354

Closed
x47188 opened this issue Feb 29, 2020 · 9 comments
Closed

Angular9: Jest + Ivy without Zone (noNgZone). #354

x47188 opened this issue Feb 29, 2020 · 9 comments
Labels
Not An Issue Not jest-preset-angular issue

Comments

@x47188
Copy link

x47188 commented Feb 29, 2020

Hey 馃檶

I was wondering if there was any documented way to run Angular 9 + Jest without zone.js ( setupJest.ts heavily relies on Zone)?

@wtho
Copy link
Collaborator

wtho commented Mar 2, 2020

Hey!

No, we just got into the first compatibility issues with Angular 9, so there's no work done on this field so far.
But you can try removing these imports in your project and report your findings!

@x47188
Copy link
Author

x47188 commented Mar 2, 2020

Removing the zone imports will raise an In this configuration Angular requires Zone.js error at boot.

Some interesting findings:

  • I'm not getting a TestBedRender3 instance from getTestBed() (probably related to the fact that I'm not using ngcc-compiled Ivy bundles).

  • Nothing is available inside current TestBedViewEngine or TestBedRender3 implementations to easily disable Zone.js (that noNgZone flag could be a potential answer though).

  • I tried toying with the injection container replacing NgZone value with a NoopNgZone etc... without success.

@ahnpnl ahnpnl added the ivy Ivy compatible label Mar 3, 2020
@ahnpnl
Copy link
Collaborator

ahnpnl commented Mar 3, 2020

I remember I tried this before, with Angular 8 or lower I also got some similar errors so I gave up about excluding zone. Angular looks like tightly coupled with zone

@wtho
Copy link
Collaborator

wtho commented Mar 3, 2020

@x47188 but if I interpret the issue right, you do have an app that runs without zone.js and you want to achieve the same in jsdom for jest, is that the case?
Then I think we should look into it.

@x47188
Copy link
Author

x47188 commented Mar 4, 2020

but if I interpret the issue right, you do have an app that runs without zone.js and you want to achieve the same in jsdom for jest, is that the case?

Absolutely.

Then I think we should look into it.

Very appreciated!

However I fear the current TestBedRender3 implementation isn't flexible enough to allow ivy-only zonejs-less rendering.

@wtho
Copy link
Collaborator

wtho commented Mar 13, 2020

Do your zoneless tests run in Karma?

@x47188
Copy link
Author

x47188 commented Mar 25, 2020

@wtho good question, I'll create a "repro" to verify that. (I've striped karma & co from my current code-base)

@wtho
Copy link
Collaborator

wtho commented Mar 25, 2020

Thanks, if you could also share it, that would be awesome!

@wtho wtho added the Needs Repo Need a minimium repository to reproduce the problem label Jul 8, 2020
@wtho wtho mentioned this issue Jul 9, 2020
@ahnpnl
Copy link
Collaborator

ahnpnl commented Dec 1, 2020

I think this depends on the development from Angular to work without zone, which is currently in roadmap https://angular.io/guide/roadmap#leverage-full-framework-capabilities-with-zonejs-opt-out

@ahnpnl ahnpnl closed this as completed Apr 30, 2021
@ahnpnl ahnpnl added Not An Issue Not jest-preset-angular issue and removed Needs Repo Need a minimium repository to reproduce the problem ivy Ivy compatible labels Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Not An Issue Not jest-preset-angular issue
Projects
None yet
Development

No branches or pull requests

3 participants