-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
bug: Angular 13 Jest Tests fail while opening overlays: Cannot set property '$lazyInstance$' of undefined (present is not a function) #24590
Comments
The same problem happens to me using Vue and the Modal component. I have tested it in browser environment, both Firefox and Chrome. In Firefox, this is the error message (an extract of it):
And in chrome instead I get:
|
Thanks for the issue. This has been resolved via #24681, and a fix will be available in an upcoming release of Ionic Framework. |
Hey @liamdebeasi I'm also facing this issue. Can you please tell me how can I update my files with your commit? Or if it's available in latest release of Ionic than what should I do to update my current versions. |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Prerequisites
Ionic Framework Version
Current Behavior
The error occurs when an alert or modal will be presented or any other function is called (e.g. onDidDismiss). Everything works fine when testing it in the browser, but if we run a jest test the following error is thrown:
We dig into this issue and see that some methods are not defined. We can create an alert with
alert.create({})
but methods like
present, onDidDismiss
are not defined.Expected Behavior
The modals or alerts can be used in jest test like in the browser. We can't reproduce this issue with ionic 5.
Steps to Reproduce
We have setup a very plain Angular 13 project with the angular cli. We added our Jest configuration to run the unit tests with Jest and added @ionic/angular 6.0.2
Everything is working fine except for
alert.create().then(alert => alert.present())
Code Reproduction URL
https://github.com/tobiloeb/ionic6-jest-issue
Ionic Info
Ionic:
Ionic CLI : 5.4.16
Utility:
cordova-res : not installed
native-run : not installed
System:
NodeJS : v14.16.1
npm : 6.14.12
OS : macOS Big Sur
Additional Information
First we thought it is a jest problem, but everything is working fin except for the ionic overlays. And we found a very similar issue for ionic/vue: #24503
In our case we already import the AlertController from '@ionic/angular' and not from core.
The text was updated successfully, but these errors were encountered: